@wordpress/edit-site 4.1.0 → 4.3.0
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/CHANGELOG.md +4 -0
- package/build/components/add-new-template/new-template-part.js +2 -9
- package/build/components/add-new-template/new-template-part.js.map +1 -1
- package/build/components/add-new-template/new-template.js +28 -12
- package/build/components/add-new-template/new-template.js.map +1 -1
- package/build/components/block-editor/index.js +53 -4
- package/build/components/block-editor/index.js.map +1 -1
- package/build/components/editor/index.js +9 -3
- package/build/components/editor/index.js.map +1 -1
- package/build/components/global-styles/border-panel.js +25 -24
- package/build/components/global-styles/border-panel.js.map +1 -1
- package/build/components/global-styles/color-indicator-wrapper.js +37 -0
- package/build/components/global-styles/color-indicator-wrapper.js.map +1 -0
- package/build/components/global-styles/dimensions-panel.js +6 -2
- package/build/components/global-styles/dimensions-panel.js.map +1 -1
- package/build/components/global-styles/header.js +1 -4
- package/build/components/global-styles/header.js.map +1 -1
- package/build/components/global-styles/icon-with-current-color.js +34 -0
- package/build/components/global-styles/icon-with-current-color.js.map +1 -0
- package/build/components/global-styles/navigation-button.js +7 -3
- package/build/components/global-styles/navigation-button.js.map +1 -1
- package/build/components/global-styles/palette.js +8 -5
- package/build/components/global-styles/palette.js.map +1 -1
- package/build/components/global-styles/preview.js +142 -26
- package/build/components/global-styles/preview.js.map +1 -1
- package/build/components/global-styles/screen-block-list.js +2 -2
- package/build/components/global-styles/screen-block-list.js.map +1 -1
- package/build/components/global-styles/screen-colors.js +11 -3
- package/build/components/global-styles/screen-colors.js.map +1 -1
- package/build/components/global-styles/screen-root.js +7 -5
- package/build/components/global-styles/screen-root.js.map +1 -1
- package/build/components/global-styles/screen-style-variations.js +12 -5
- package/build/components/global-styles/screen-style-variations.js.map +1 -1
- package/build/components/header/document-actions/index.js +13 -11
- package/build/components/header/document-actions/index.js.map +1 -1
- package/build/components/header/index.js +5 -3
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +9 -1
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/header/more-menu/site-export.js +5 -2
- package/build/components/header/more-menu/site-export.js.map +1 -1
- package/build/components/header/plugin-more-menu-item/index.js +5 -0
- package/build/components/header/plugin-more-menu-item/index.js.map +1 -1
- package/build/components/list/actions/rename-menu-item.js +3 -10
- package/build/components/list/actions/rename-menu-item.js.map +1 -1
- package/build/components/preferences-modal/enable-feature.js +40 -0
- package/build/components/preferences-modal/enable-feature.js.map +1 -0
- package/build/components/preferences-modal/index.js +68 -0
- package/build/components/preferences-modal/index.js.map +1 -0
- package/build/components/sidebar/index.js +12 -1
- package/build/components/sidebar/index.js.map +1 -1
- package/build/components/sidebar/navigation-menu-sidebar/index.js +40 -0
- package/build/components/sidebar/navigation-menu-sidebar/index.js.map +1 -0
- package/build/components/sidebar/navigation-menu-sidebar/navigation-inspector.js +185 -0
- package/build/components/sidebar/navigation-menu-sidebar/navigation-inspector.js.map +1 -0
- package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js +54 -0
- package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -0
- package/build/components/template-part-converter/convert-to-regular.js +6 -0
- package/build/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/store/actions.js +3 -3
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +3 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/add-new-template/new-template-part.js +3 -10
- package/build-module/components/add-new-template/new-template-part.js.map +1 -1
- package/build-module/components/add-new-template/new-template.js +27 -12
- package/build-module/components/add-new-template/new-template.js.map +1 -1
- package/build-module/components/block-editor/index.js +51 -6
- package/build-module/components/block-editor/index.js.map +1 -1
- package/build-module/components/editor/index.js +8 -3
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +27 -26
- package/build-module/components/global-styles/border-panel.js.map +1 -1
- package/build-module/components/global-styles/color-indicator-wrapper.js +25 -0
- package/build-module/components/global-styles/color-indicator-wrapper.js.map +1 -0
- package/build-module/components/global-styles/dimensions-panel.js +6 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
- package/build-module/components/global-styles/header.js +2 -5
- package/build-module/components/global-styles/header.js.map +1 -1
- package/build-module/components/global-styles/icon-with-current-color.js +22 -0
- package/build-module/components/global-styles/icon-with-current-color.js.map +1 -0
- package/build-module/components/global-styles/navigation-button.js +7 -3
- package/build-module/components/global-styles/navigation-button.js.map +1 -1
- package/build-module/components/global-styles/palette.js +8 -6
- package/build-module/components/global-styles/palette.js.map +1 -1
- package/build-module/components/global-styles/preview.js +141 -27
- package/build-module/components/global-styles/preview.js.map +1 -1
- package/build-module/components/global-styles/screen-block-list.js +2 -2
- package/build-module/components/global-styles/screen-block-list.js.map +1 -1
- package/build-module/components/global-styles/screen-colors.js +10 -3
- package/build-module/components/global-styles/screen-colors.js.map +1 -1
- package/build-module/components/global-styles/screen-root.js +8 -7
- package/build-module/components/global-styles/screen-root.js.map +1 -1
- package/build-module/components/global-styles/screen-style-variations.js +13 -6
- package/build-module/components/global-styles/screen-style-variations.js.map +1 -1
- package/build-module/components/header/document-actions/index.js +13 -11
- package/build-module/components/header/document-actions/index.js.map +1 -1
- package/build-module/components/header/index.js +5 -3
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +8 -1
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/header/more-menu/site-export.js +5 -2
- package/build-module/components/header/more-menu/site-export.js.map +1 -1
- package/build-module/components/header/plugin-more-menu-item/index.js +4 -0
- package/build-module/components/header/plugin-more-menu-item/index.js.map +1 -1
- package/build-module/components/list/actions/rename-menu-item.js +4 -11
- package/build-module/components/list/actions/rename-menu-item.js.map +1 -1
- package/build-module/components/preferences-modal/enable-feature.js +27 -0
- package/build-module/components/preferences-modal/enable-feature.js.map +1 -0
- package/build-module/components/preferences-modal/index.js +57 -0
- package/build-module/components/preferences-modal/index.js.map +1 -0
- package/build-module/components/sidebar/index.js +11 -1
- package/build-module/components/sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/navigation-menu-sidebar/index.js +26 -0
- package/build-module/components/sidebar/navigation-menu-sidebar/index.js.map +1 -0
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-inspector.js +168 -0
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-inspector.js.map +1 -0
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js +45 -0
- package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -0
- package/build-module/components/template-part-converter/convert-to-regular.js +6 -0
- package/build-module/components/template-part-converter/convert-to-regular.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-module/store/actions.js +3 -3
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +3 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +86 -5
- package/build-style/style.css +86 -5
- package/package.json +29 -29
- package/src/components/add-new-template/new-template-part.js +3 -12
- package/src/components/add-new-template/new-template.js +49 -12
- package/src/components/block-editor/index.js +79 -9
- package/src/components/editor/index.js +13 -0
- package/src/components/global-styles/border-panel.js +32 -26
- package/src/components/global-styles/color-indicator-wrapper.js +23 -0
- package/src/components/global-styles/dimensions-panel.js +7 -2
- package/src/components/global-styles/header.js +2 -7
- package/src/components/global-styles/icon-with-current-color.js +21 -0
- package/src/components/global-styles/navigation-button.js +6 -4
- package/src/components/global-styles/palette.js +8 -11
- package/src/components/global-styles/preview.js +186 -29
- package/src/components/global-styles/screen-block-list.js +1 -3
- package/src/components/global-styles/screen-colors.js +7 -6
- package/src/components/global-styles/screen-root.js +15 -17
- package/src/components/global-styles/screen-style-variations.js +13 -4
- package/src/components/global-styles/style.scss +18 -6
- package/src/components/header/document-actions/index.js +14 -10
- package/src/components/header/index.js +6 -1
- package/src/components/header/more-menu/index.js +15 -0
- package/src/components/header/more-menu/site-export.js +13 -2
- package/src/components/header/plugin-more-menu-item/index.js +2 -0
- package/src/components/header/style.scss +45 -0
- package/src/components/list/actions/rename-menu-item.js +3 -13
- package/src/components/preferences-modal/enable-feature.js +24 -0
- package/src/components/preferences-modal/index.js +76 -0
- package/src/components/sidebar/index.js +12 -0
- package/src/components/sidebar/navigation-menu-sidebar/index.js +34 -0
- package/src/components/sidebar/navigation-menu-sidebar/navigation-inspector.js +224 -0
- package/src/components/sidebar/navigation-menu-sidebar/navigation-menu.js +62 -0
- package/src/components/sidebar/navigation-menu-sidebar/style.scss +42 -0
- package/src/components/sidebar/style.scss +1 -1
- package/src/components/template-part-converter/convert-to-regular.js +9 -0
- package/src/index.js +1 -0
- package/src/store/actions.js +4 -4
- package/src/store/selectors.js +10 -0
- package/src/store/test/selectors.js +4 -0
- package/src/style.scss +1 -0
|
@@ -0,0 +1,40 @@
|
|
|
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 = EnableFeature;
|
|
9
|
+
|
|
10
|
+
var _element = require("@wordpress/element");
|
|
11
|
+
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
14
|
+
var _data = require("@wordpress/data");
|
|
15
|
+
|
|
16
|
+
var _interface = require("@wordpress/interface");
|
|
17
|
+
|
|
18
|
+
var _preferences = require("@wordpress/preferences");
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* WordPress dependencies
|
|
22
|
+
*/
|
|
23
|
+
function EnableFeature(props) {
|
|
24
|
+
const {
|
|
25
|
+
featureName,
|
|
26
|
+
...remainingProps
|
|
27
|
+
} = props;
|
|
28
|
+
const isChecked = (0, _data.useSelect)(select => !!select(_preferences.store).get('core/edit-site', featureName), [featureName]);
|
|
29
|
+
const {
|
|
30
|
+
toggle
|
|
31
|
+
} = (0, _data.useDispatch)(_preferences.store);
|
|
32
|
+
|
|
33
|
+
const onChange = () => toggle('core/edit-site', featureName);
|
|
34
|
+
|
|
35
|
+
return (0, _element.createElement)(_interface.___unstablePreferencesModalBaseOption, (0, _extends2.default)({
|
|
36
|
+
onChange: onChange,
|
|
37
|
+
isChecked: isChecked
|
|
38
|
+
}, remainingProps));
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=enable-feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/preferences-modal/enable-feature.js"],"names":["EnableFeature","props","featureName","remainingProps","isChecked","select","preferencesStore","get","toggle","onChange"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAKe,SAASA,aAAT,CAAwBC,KAAxB,EAAgC;AAC9C,QAAM;AAAEC,IAAAA,WAAF;AAAe,OAAGC;AAAlB,MAAqCF,KAA3C;AACA,QAAMG,SAAS,GAAG,qBACfC,MAAF,IACC,CAAC,CAAEA,MAAM,CAAEC,kBAAF,CAAN,CAA2BC,GAA3B,CAAgC,gBAAhC,EAAkDL,WAAlD,CAFa,EAGjB,CAAEA,WAAF,CAHiB,CAAlB;AAKA,QAAM;AAAEM,IAAAA;AAAF,MAAa,uBAAaF,kBAAb,CAAnB;;AACA,QAAMG,QAAQ,GAAG,MAAMD,MAAM,CAAE,gBAAF,EAAoBN,WAApB,CAA7B;;AACA,SACC,4BAAC,gDAAD;AACC,IAAA,QAAQ,EAAGO,QADZ;AAEC,IAAA,SAAS,EAAGL;AAFb,KAGMD,cAHN,EADD;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { ___unstablePreferencesModalBaseOption as BaseOption } from '@wordpress/interface';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\nexport default function EnableFeature( props ) {\n\tconst { featureName, ...remainingProps } = props;\n\tconst isChecked = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( preferencesStore ).get( 'core/edit-site', featureName ),\n\t\t[ featureName ]\n\t);\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst onChange = () => toggle( 'core/edit-site', featureName );\n\treturn (\n\t\t<BaseOption\n\t\t\tonChange={ onChange }\n\t\t\tisChecked={ isChecked }\n\t\t\t{ ...remainingProps }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
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 = EditSitePreferencesModal;
|
|
9
|
+
|
|
10
|
+
var _element = require("@wordpress/element");
|
|
11
|
+
|
|
12
|
+
var _interface = require("@wordpress/interface");
|
|
13
|
+
|
|
14
|
+
var _i18n = require("@wordpress/i18n");
|
|
15
|
+
|
|
16
|
+
var _enableFeature = _interopRequireDefault(require("./enable-feature"));
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* WordPress dependencies
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Internal dependencies
|
|
24
|
+
*/
|
|
25
|
+
function EditSitePreferencesModal(_ref) {
|
|
26
|
+
let {
|
|
27
|
+
isModalActive,
|
|
28
|
+
toggleModal
|
|
29
|
+
} = _ref;
|
|
30
|
+
const sections = (0, _element.useMemo)(() => [{
|
|
31
|
+
name: 'general',
|
|
32
|
+
tabLabel: (0, _i18n.__)('General'),
|
|
33
|
+
content: (0, _element.createElement)(_interface.PreferencesModalSection, {
|
|
34
|
+
title: (0, _i18n.__)('Appearance'),
|
|
35
|
+
description: (0, _i18n.__)('Customize options related to the block editor interface and editing flow.')
|
|
36
|
+
}, (0, _element.createElement)(_enableFeature.default, {
|
|
37
|
+
featureName: "focusMode",
|
|
38
|
+
help: (0, _i18n.__)('Highlights the current block and fades other content.'),
|
|
39
|
+
label: (0, _i18n.__)('Spotlight mode')
|
|
40
|
+
}), (0, _element.createElement)(_enableFeature.default, {
|
|
41
|
+
featureName: "showIconLabels",
|
|
42
|
+
label: (0, _i18n.__)('Show button text labels'),
|
|
43
|
+
help: (0, _i18n.__)('Show text instead of icons on buttons')
|
|
44
|
+
}))
|
|
45
|
+
}, {
|
|
46
|
+
name: 'blocks',
|
|
47
|
+
tabLabel: (0, _i18n.__)('Blocks'),
|
|
48
|
+
content: (0, _element.createElement)(_interface.PreferencesModalSection, {
|
|
49
|
+
title: (0, _i18n.__)('Block interactions'),
|
|
50
|
+
description: (0, _i18n.__)('Customize how you interact with blocks in the block library and editing canvas.')
|
|
51
|
+
}, (0, _element.createElement)(_enableFeature.default, {
|
|
52
|
+
featureName: "keepCaretInsideBlock",
|
|
53
|
+
help: (0, _i18n.__)('Aids screen readers by stopping text caret from leaving blocks.'),
|
|
54
|
+
label: (0, _i18n.__)('Contain text cursor inside block')
|
|
55
|
+
}))
|
|
56
|
+
}]);
|
|
57
|
+
|
|
58
|
+
if (!isModalActive) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return (0, _element.createElement)(_interface.PreferencesModal, {
|
|
63
|
+
closeModal: toggleModal
|
|
64
|
+
}, (0, _element.createElement)(_interface.PreferencesModalTabs, {
|
|
65
|
+
sections: sections
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/preferences-modal/index.js"],"names":["EditSitePreferencesModal","isModalActive","toggleModal","sections","name","tabLabel","content"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AAKA;;AAdA;AACA;AACA;;AASA;AACA;AACA;AAGe,SAASA,wBAAT,OAGX;AAAA,MAH8C;AACjDC,IAAAA,aADiD;AAEjDC,IAAAA;AAFiD,GAG9C;AACH,QAAMC,QAAQ,GAAG,sBAAS,MAAM,CAC/B;AACCC,IAAAA,IAAI,EAAE,SADP;AAECC,IAAAA,QAAQ,EAAE,cAAI,SAAJ,CAFX;AAGCC,IAAAA,OAAO,EACN,4BAAC,kCAAD;AACC,MAAA,KAAK,EAAG,cAAI,YAAJ,CADT;AAEC,MAAA,WAAW,EAAG,cACb,2EADa;AAFf,OAMC,4BAAC,sBAAD;AACC,MAAA,WAAW,EAAC,WADb;AAEC,MAAA,IAAI,EAAG,cACN,uDADM,CAFR;AAKC,MAAA,KAAK,EAAG,cAAI,gBAAJ;AALT,MAND,EAaC,4BAAC,sBAAD;AACC,MAAA,WAAW,EAAC,gBADb;AAEC,MAAA,KAAK,EAAG,cAAI,yBAAJ,CAFT;AAGC,MAAA,IAAI,EAAG,cAAI,uCAAJ;AAHR,MAbD;AAJF,GAD+B,EA0B/B;AACCF,IAAAA,IAAI,EAAE,QADP;AAECC,IAAAA,QAAQ,EAAE,cAAI,QAAJ,CAFX;AAGCC,IAAAA,OAAO,EACN,4BAAC,kCAAD;AACC,MAAA,KAAK,EAAG,cAAI,oBAAJ,CADT;AAEC,MAAA,WAAW,EAAG,cACb,iFADa;AAFf,OAMC,4BAAC,sBAAD;AACC,MAAA,WAAW,EAAC,sBADb;AAEC,MAAA,IAAI,EAAG,cACN,iEADM,CAFR;AAKC,MAAA,KAAK,EAAG,cAAI,kCAAJ;AALT,MAND;AAJF,GA1B+B,CAAf,CAAjB;;AA+CA,MAAK,CAAEL,aAAP,EAAuB;AACtB,WAAO,IAAP;AACA;;AACD,SACC,4BAAC,2BAAD;AAAkB,IAAA,UAAU,EAAGC;AAA/B,KACC,4BAAC,+BAAD;AAAsB,IAAA,QAAQ,EAAGC;AAAjC,IADD,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPreferencesModal,\n\tPreferencesModalTabs,\n\tPreferencesModalSection,\n} from '@wordpress/interface';\nimport { useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport EnableFeature from './enable-feature';\n\nexport default function EditSitePreferencesModal( {\n\tisModalActive,\n\ttoggleModal,\n} ) {\n\tconst sections = useMemo( () => [\n\t\t{\n\t\t\tname: 'general',\n\t\t\ttabLabel: __( 'General' ),\n\t\t\tcontent: (\n\t\t\t\t<PreferencesModalSection\n\t\t\t\t\ttitle={ __( 'Appearance' ) }\n\t\t\t\t\tdescription={ __(\n\t\t\t\t\t\t'Customize options related to the block editor interface and editing flow.'\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t<EnableFeature\n\t\t\t\t\t\tfeatureName=\"focusMode\"\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Highlights the current block and fades other content.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tlabel={ __( 'Spotlight mode' ) }\n\t\t\t\t\t/>\n\t\t\t\t\t<EnableFeature\n\t\t\t\t\t\tfeatureName=\"showIconLabels\"\n\t\t\t\t\t\tlabel={ __( 'Show button text labels' ) }\n\t\t\t\t\t\thelp={ __( 'Show text instead of icons on buttons' ) }\n\t\t\t\t\t/>\n\t\t\t\t</PreferencesModalSection>\n\t\t\t),\n\t\t},\n\t\t{\n\t\t\tname: 'blocks',\n\t\t\ttabLabel: __( 'Blocks' ),\n\t\t\tcontent: (\n\t\t\t\t<PreferencesModalSection\n\t\t\t\t\ttitle={ __( 'Block interactions' ) }\n\t\t\t\t\tdescription={ __(\n\t\t\t\t\t\t'Customize how you interact with blocks in the block library and editing canvas.'\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t<EnableFeature\n\t\t\t\t\t\tfeatureName=\"keepCaretInsideBlock\"\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Aids screen readers by stopping text caret from leaving blocks.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tlabel={ __( 'Contain text cursor inside block' ) }\n\t\t\t\t\t/>\n\t\t\t\t</PreferencesModalSection>\n\t\t\t),\n\t\t},\n\t] );\n\tif ( ! isModalActive ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<PreferencesModal closeModal={ toggleModal }>\n\t\t\t<PreferencesModalTabs sections={ sections } />\n\t\t</PreferencesModal>\n\t);\n}\n"]}
|
|
@@ -26,6 +26,8 @@ var _defaultSidebar = _interopRequireDefault(require("./default-sidebar"));
|
|
|
26
26
|
|
|
27
27
|
var _globalStylesSidebar = _interopRequireDefault(require("./global-styles-sidebar"));
|
|
28
28
|
|
|
29
|
+
var _navigationMenuSidebar = _interopRequireDefault(require("./navigation-menu-sidebar"));
|
|
30
|
+
|
|
29
31
|
var _constants = require("../../store/constants");
|
|
30
32
|
|
|
31
33
|
var _settingsHeader = _interopRequireDefault(require("./settings-header"));
|
|
@@ -80,6 +82,15 @@ function SidebarComplementaryAreaFills() {
|
|
|
80
82
|
|
|
81
83
|
if (!isEditorSidebarOpened) {
|
|
82
84
|
sidebarName = hasBlockSelection ? _constants2.SIDEBAR_BLOCK : _constants2.SIDEBAR_TEMPLATE;
|
|
85
|
+
} // Conditionally include NavMenu sidebar in Plugin only.
|
|
86
|
+
// Optimise for dead code elimination.
|
|
87
|
+
// See https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/feature-flags.md#dead-code-elimination.
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
let MaybeNavigationMenuSidebar = 'Fragment';
|
|
91
|
+
|
|
92
|
+
if (process.env.IS_GUTENBERG_PLUGIN) {
|
|
93
|
+
MaybeNavigationMenuSidebar = _navigationMenuSidebar.default;
|
|
83
94
|
}
|
|
84
95
|
|
|
85
96
|
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_defaultSidebar.default, {
|
|
@@ -93,6 +104,6 @@ function SidebarComplementaryAreaFills() {
|
|
|
93
104
|
headerClassName: "edit-site-sidebar__panel-tabs"
|
|
94
105
|
}, sidebarName === _constants2.SIDEBAR_TEMPLATE && (0, _element.createElement)(_components.PanelBody, null, (0, _element.createElement)(_templateCard.default, null)), sidebarName === _constants2.SIDEBAR_BLOCK && (0, _element.createElement)(InspectorSlot, {
|
|
95
106
|
bubblesVirtually: true
|
|
96
|
-
})), (0, _element.createElement)(_globalStylesSidebar.default, null));
|
|
107
|
+
})), (0, _element.createElement)(_globalStylesSidebar.default, null), (0, _element.createElement)(MaybeNavigationMenuSidebar, null));
|
|
97
108
|
}
|
|
98
109
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/index.js"],"names":["Slot","InspectorSlot","Fill","InspectorFill","SidebarInspectorFill","SidebarComplementaryAreaFills","sidebar","isEditorSidebarOpened","hasBlockSelection","select","_sidebar","interfaceStore","getActiveComplementaryArea","STORE_NAME","_isEditorSidebarOpened","SIDEBAR_BLOCK","SIDEBAR_TEMPLATE","includes","blockEditorStore","getBlockSelectionStart","enableComplementaryArea","sidebarName","cog"],"mappings":";;;;;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/index.js"],"names":["Slot","InspectorSlot","Fill","InspectorFill","SidebarInspectorFill","SidebarComplementaryAreaFills","sidebar","isEditorSidebarOpened","hasBlockSelection","select","_sidebar","interfaceStore","getActiveComplementaryArea","STORE_NAME","_isEditorSidebarOpened","SIDEBAR_BLOCK","SIDEBAR_TEMPLATE","includes","blockEditorStore","getBlockSelectionStart","enableComplementaryArea","sidebarName","MaybeNavigationMenuSidebar","process","env","IS_GUTENBERG_PLUGIN","NavigationMenuSidebar","cog"],"mappings":";;;;;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AApBA;AACA;AACA;;AASA;AACA;AACA;AASA,MAAM;AAAEA,EA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,CAACC,GAAR,CAAYC,mBAAjB,EAAuC;AACtCH,IAAAA,0BAA0B,GAAGI,8BAA7B;AACA;;AAED,SACC,qDACC,4BAAC,uBAAD;AACC,IAAA,UAAU,EAAGL,WADd;AAEC,IAAA,KAAK,EAAG,cAAI,UAAJ,CAFT;AAGC,IAAA,IAAI,EAAGM,UAHR;AAIC,IAAA,UAAU,EAAG,cAAI,wBAAJ,CAJd;AAKC,IAAA,MAAM,EAAG,4BAAC,uBAAD;AAAgB,MAAA,WAAW,EAAGN;AAA9B,MALV;AAMC,IAAA,eAAe,EAAC;AANjB,KAQGA,WAAW,KAAKL,4BAAhB,IACD,4BAAC,qBAAD,QACC,4BAAC,qBAAD,OADD,CATF,EAaGK,WAAW,KAAKN,yBAAhB,IACD,4BAAC,aAAD;AAAe,IAAA,gBAAgB;AAA/B,IAdF,CADD,EAkBC,4BAAC,4BAAD,OAlBD,EAmBC,4BAAC,0BAAD,OAnBD,CADD;AAuBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSlotFill, PanelBody } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { cog } from '@wordpress/icons';\nimport { useEffect } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport DefaultSidebar from './default-sidebar';\nimport GlobalStylesSidebar from './global-styles-sidebar';\nimport NavigationMenuSidebar from './navigation-menu-sidebar';\nimport { STORE_NAME } from '../../store/constants';\nimport SettingsHeader from './settings-header';\nimport TemplateCard from './template-card';\nimport { SIDEBAR_BLOCK, SIDEBAR_TEMPLATE } from './constants';\n\nconst { Slot: InspectorSlot, Fill: InspectorFill } = createSlotFill(\n\t'EditSiteSidebarInspector'\n);\nexport const SidebarInspectorFill = InspectorFill;\n\nexport function SidebarComplementaryAreaFills() {\n\tconst { sidebar, isEditorSidebarOpened, hasBlockSelection } = useSelect(\n\t\t( select ) => {\n\t\t\tconst _sidebar = select(\n\t\t\t\tinterfaceStore\n\t\t\t).getActiveComplementaryArea( STORE_NAME );\n\t\t\tconst _isEditorSidebarOpened = [\n\t\t\t\tSIDEBAR_BLOCK,\n\t\t\t\tSIDEBAR_TEMPLATE,\n\t\t\t].includes( _sidebar );\n\t\t\treturn {\n\t\t\t\tsidebar: _sidebar,\n\t\t\t\tisEditorSidebarOpened: _isEditorSidebarOpened,\n\t\t\t\thasBlockSelection: !! select(\n\t\t\t\t\tblockEditorStore\n\t\t\t\t).getBlockSelectionStart(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\tuseEffect( () => {\n\t\tif ( ! isEditorSidebarOpened ) return;\n\t\tif ( hasBlockSelection ) {\n\t\t\tenableComplementaryArea( STORE_NAME, SIDEBAR_BLOCK );\n\t\t} else {\n\t\t\tenableComplementaryArea( STORE_NAME, SIDEBAR_TEMPLATE );\n\t\t}\n\t}, [ hasBlockSelection, isEditorSidebarOpened ] );\n\tlet sidebarName = sidebar;\n\tif ( ! isEditorSidebarOpened ) {\n\t\tsidebarName = hasBlockSelection ? SIDEBAR_BLOCK : SIDEBAR_TEMPLATE;\n\t}\n\n\t// Conditionally include NavMenu sidebar in Plugin only.\n\t// Optimise for dead code elimination.\n\t// See https://github.com/WordPress/gutenberg/blob/trunk/docs/how-to-guides/feature-flags.md#dead-code-elimination.\n\tlet MaybeNavigationMenuSidebar = 'Fragment';\n\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\tMaybeNavigationMenuSidebar = NavigationMenuSidebar;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<DefaultSidebar\n\t\t\t\tidentifier={ sidebarName }\n\t\t\t\ttitle={ __( 'Settings' ) }\n\t\t\t\ticon={ cog }\n\t\t\t\tcloseLabel={ __( 'Close settings sidebar' ) }\n\t\t\t\theader={ <SettingsHeader sidebarName={ sidebarName } /> }\n\t\t\t\theaderClassName=\"edit-site-sidebar__panel-tabs\"\n\t\t\t>\n\t\t\t\t{ sidebarName === SIDEBAR_TEMPLATE && (\n\t\t\t\t\t<PanelBody>\n\t\t\t\t\t\t<TemplateCard />\n\t\t\t\t\t</PanelBody>\n\t\t\t\t) }\n\t\t\t\t{ sidebarName === SIDEBAR_BLOCK && (\n\t\t\t\t\t<InspectorSlot bubblesVirtually />\n\t\t\t\t) }\n\t\t\t</DefaultSidebar>\n\t\t\t<GlobalStylesSidebar />\n\t\t\t<MaybeNavigationMenuSidebar />\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
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 = NavigationMenuSidebar;
|
|
9
|
+
|
|
10
|
+
var _element = require("@wordpress/element");
|
|
11
|
+
|
|
12
|
+
var _components = require("@wordpress/components");
|
|
13
|
+
|
|
14
|
+
var _i18n = require("@wordpress/i18n");
|
|
15
|
+
|
|
16
|
+
var _icons = require("@wordpress/icons");
|
|
17
|
+
|
|
18
|
+
var _defaultSidebar = _interopRequireDefault(require("../default-sidebar"));
|
|
19
|
+
|
|
20
|
+
var _navigationInspector = _interopRequireDefault(require("./navigation-inspector"));
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* WordPress dependencies
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Internal dependencies
|
|
28
|
+
*/
|
|
29
|
+
function NavigationMenuSidebar() {
|
|
30
|
+
return (0, _element.createElement)(_defaultSidebar.default, {
|
|
31
|
+
className: "edit-site-navigation-menu-sidebar",
|
|
32
|
+
identifier: "edit-site/navigation-menu",
|
|
33
|
+
title: (0, _i18n.__)('Navigation Menus'),
|
|
34
|
+
icon: _icons.navigation,
|
|
35
|
+
closeLabel: (0, _i18n.__)('Close navigation menu sidebar'),
|
|
36
|
+
panelClassName: "edit-site-navigation-menu-sidebar__panel",
|
|
37
|
+
header: (0, _element.createElement)(_components.Flex, null, (0, _element.createElement)(_components.FlexBlock, null, (0, _element.createElement)("strong", null, (0, _i18n.__)('Navigation Menus'))))
|
|
38
|
+
}, (0, _element.createElement)(_navigationInspector.default, null));
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/navigation-menu-sidebar/index.js"],"names":["NavigationMenuSidebar","navigation"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;AAIe,SAASA,qBAAT,GAAiC;AAC/C,SACC,4BAAC,uBAAD;AACC,IAAA,SAAS,EAAC,mCADX;AAEC,IAAA,UAAU,EAAC,2BAFZ;AAGC,IAAA,KAAK,EAAG,cAAI,kBAAJ,CAHT;AAIC,IAAA,IAAI,EAAGC,iBAJR;AAKC,IAAA,UAAU,EAAG,cAAI,+BAAJ,CALd;AAMC,IAAA,cAAc,EAAC,0CANhB;AAOC,IAAA,MAAM,EACL,4BAAC,gBAAD,QACC,4BAAC,qBAAD,QACC,4CAAU,cAAI,kBAAJ,CAAV,CADD,CADD;AARF,KAeC,4BAAC,4BAAD,OAfD,CADD;AAmBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { FlexBlock, Flex } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { navigation } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport DefaultSidebar from '../default-sidebar';\nimport NavigationInspector from './navigation-inspector';\n\nexport default function NavigationMenuSidebar() {\n\treturn (\n\t\t<DefaultSidebar\n\t\t\tclassName=\"edit-site-navigation-menu-sidebar\"\n\t\t\tidentifier=\"edit-site/navigation-menu\"\n\t\t\ttitle={ __( 'Navigation Menus' ) }\n\t\t\ticon={ navigation }\n\t\t\tcloseLabel={ __( 'Close navigation menu sidebar' ) }\n\t\t\tpanelClassName=\"edit-site-navigation-menu-sidebar__panel\"\n\t\t\theader={\n\t\t\t\t<Flex>\n\t\t\t\t\t<FlexBlock>\n\t\t\t\t\t\t<strong>{ __( 'Navigation Menus' ) }</strong>\n\t\t\t\t\t</FlexBlock>\n\t\t\t\t</Flex>\n\t\t\t}\n\t\t>\n\t\t\t<NavigationInspector />\n\t\t</DefaultSidebar>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,185 @@
|
|
|
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 = NavigationInspector;
|
|
9
|
+
|
|
10
|
+
var _element = require("@wordpress/element");
|
|
11
|
+
|
|
12
|
+
var _data = require("@wordpress/data");
|
|
13
|
+
|
|
14
|
+
var _components = require("@wordpress/components");
|
|
15
|
+
|
|
16
|
+
var _coreData = require("@wordpress/core-data");
|
|
17
|
+
|
|
18
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
19
|
+
|
|
20
|
+
var _a11y = require("@wordpress/a11y");
|
|
21
|
+
|
|
22
|
+
var _compose = require("@wordpress/compose");
|
|
23
|
+
|
|
24
|
+
var _i18n = require("@wordpress/i18n");
|
|
25
|
+
|
|
26
|
+
var _navigationMenu = _interopRequireDefault(require("./navigation-menu"));
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* WordPress dependencies
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Internal dependencies
|
|
34
|
+
*/
|
|
35
|
+
const NAVIGATION_MENUS_QUERY = [{
|
|
36
|
+
per_page: -1,
|
|
37
|
+
status: 'publish'
|
|
38
|
+
}];
|
|
39
|
+
|
|
40
|
+
function NavigationInspector() {
|
|
41
|
+
var _navigationMenus$;
|
|
42
|
+
|
|
43
|
+
const {
|
|
44
|
+
selectedNavigationBlockId,
|
|
45
|
+
clientIdToRef,
|
|
46
|
+
navigationMenus,
|
|
47
|
+
isResolvingNavigationMenus,
|
|
48
|
+
hasResolvedNavigationMenus,
|
|
49
|
+
firstNavigationBlockId
|
|
50
|
+
} = (0, _data.useSelect)(select => {
|
|
51
|
+
const {
|
|
52
|
+
__experimentalGetActiveBlockIdByBlockNames,
|
|
53
|
+
__experimentalGetGlobalBlocksByName,
|
|
54
|
+
getBlock
|
|
55
|
+
} = select(_blockEditor.store);
|
|
56
|
+
const {
|
|
57
|
+
getEntityRecords,
|
|
58
|
+
hasFinishedResolution,
|
|
59
|
+
isResolving
|
|
60
|
+
} = select(_coreData.store);
|
|
61
|
+
const navigationMenusQuery = ['postType', 'wp_navigation', NAVIGATION_MENUS_QUERY[0]]; // Get the active Navigation block (if present).
|
|
62
|
+
|
|
63
|
+
const selectedNavId = __experimentalGetActiveBlockIdByBlockNames('core/navigation'); // Get all Navigation blocks currently within the editor canvas.
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
const navBlockIds = __experimentalGetGlobalBlocksByName('core/navigation');
|
|
67
|
+
|
|
68
|
+
const idToRef = {};
|
|
69
|
+
navBlockIds.forEach(id => {
|
|
70
|
+
var _getBlock, _getBlock$attributes;
|
|
71
|
+
|
|
72
|
+
idToRef[id] = (_getBlock = getBlock(id)) === null || _getBlock === void 0 ? void 0 : (_getBlock$attributes = _getBlock.attributes) === null || _getBlock$attributes === void 0 ? void 0 : _getBlock$attributes.ref;
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
selectedNavigationBlockId: selectedNavId,
|
|
76
|
+
firstNavigationBlockId: navBlockIds === null || navBlockIds === void 0 ? void 0 : navBlockIds[0],
|
|
77
|
+
clientIdToRef: idToRef,
|
|
78
|
+
navigationMenus: getEntityRecords(...navigationMenusQuery),
|
|
79
|
+
isResolvingNavigationMenus: isResolving('getEntityRecords', navigationMenusQuery),
|
|
80
|
+
hasResolvedNavigationMenus: hasFinishedResolution('getEntityRecords', navigationMenusQuery)
|
|
81
|
+
};
|
|
82
|
+
}, []);
|
|
83
|
+
const navMenuListId = (0, _compose.useInstanceId)(_navigationMenu.default, 'edit-site-navigation-inspector-menu');
|
|
84
|
+
const firstNavRefInTemplate = clientIdToRef[firstNavigationBlockId];
|
|
85
|
+
const firstNavigationMenuRef = navigationMenus === null || navigationMenus === void 0 ? void 0 : (_navigationMenus$ = navigationMenus[0]) === null || _navigationMenus$ === void 0 ? void 0 : _navigationMenus$.id; // Default Navigation Menu is either:
|
|
86
|
+
// - the Navigation Menu referenced by the first Nav block within the template.
|
|
87
|
+
// - the first of the available Navigation Menus (`wp_navigation`) posts.
|
|
88
|
+
|
|
89
|
+
const defaultNavigationMenuId = firstNavRefInTemplate || firstNavigationMenuRef; // The Navigation Menu manually selected by the user within the Nav inspector.
|
|
90
|
+
|
|
91
|
+
const [currentMenuId, setCurrentMenuId] = (0, _element.useState)(firstNavRefInTemplate); // If a Nav block is selected within the canvas then set the
|
|
92
|
+
// Navigation Menu referenced by it's `ref` attribute to be
|
|
93
|
+
// active within the Navigation sidebar.
|
|
94
|
+
|
|
95
|
+
(0, _element.useEffect)(() => {
|
|
96
|
+
if (selectedNavigationBlockId) {
|
|
97
|
+
setCurrentMenuId(clientIdToRef[selectedNavigationBlockId]);
|
|
98
|
+
}
|
|
99
|
+
}, [selectedNavigationBlockId]);
|
|
100
|
+
let options = [];
|
|
101
|
+
|
|
102
|
+
if (navigationMenus) {
|
|
103
|
+
options = navigationMenus.map(_ref => {
|
|
104
|
+
let {
|
|
105
|
+
id,
|
|
106
|
+
title
|
|
107
|
+
} = _ref;
|
|
108
|
+
return {
|
|
109
|
+
value: id,
|
|
110
|
+
label: title.rendered
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const [innerBlocks, onInput, onChange] = (0, _coreData.useEntityBlockEditor)('postType', 'wp_navigation', {
|
|
116
|
+
id: currentMenuId || defaultNavigationMenuId
|
|
117
|
+
});
|
|
118
|
+
const {
|
|
119
|
+
isLoadingInnerBlocks,
|
|
120
|
+
hasLoadedInnerBlocks
|
|
121
|
+
} = (0, _data.useSelect)(select => {
|
|
122
|
+
const {
|
|
123
|
+
isResolving,
|
|
124
|
+
hasFinishedResolution
|
|
125
|
+
} = select(_coreData.store);
|
|
126
|
+
return {
|
|
127
|
+
isLoadingInnerBlocks: isResolving('getEntityRecord', ['postType', 'wp_navigation', currentMenuId || defaultNavigationMenuId]),
|
|
128
|
+
hasLoadedInnerBlocks: hasFinishedResolution('getEntityRecord', ['postType', 'wp_navigation', currentMenuId || defaultNavigationMenuId])
|
|
129
|
+
};
|
|
130
|
+
}, [currentMenuId, defaultNavigationMenuId]);
|
|
131
|
+
const isLoading = !(hasResolvedNavigationMenus && hasLoadedInnerBlocks);
|
|
132
|
+
const hasMoreThanOneNavigationMenu = (navigationMenus === null || navigationMenus === void 0 ? void 0 : navigationMenus.length) > 1;
|
|
133
|
+
const hasNavigationMenus = !!(navigationMenus !== null && navigationMenus !== void 0 && navigationMenus.length); // Entity block editor will return entities that are not currently published.
|
|
134
|
+
// Guard by only allowing their usage if there are published Nav Menus.
|
|
135
|
+
|
|
136
|
+
const publishedInnerBlocks = hasNavigationMenus ? innerBlocks : [];
|
|
137
|
+
const hasInnerBlocks = !!(publishedInnerBlocks !== null && publishedInnerBlocks !== void 0 && publishedInnerBlocks.length);
|
|
138
|
+
(0, _element.useEffect)(() => {
|
|
139
|
+
if (isResolvingNavigationMenus) {
|
|
140
|
+
(0, _a11y.speak)('Loading Navigation sidebar menus.');
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (hasResolvedNavigationMenus) {
|
|
144
|
+
(0, _a11y.speak)('Navigation sidebar menus have loaded.');
|
|
145
|
+
}
|
|
146
|
+
}, [isResolvingNavigationMenus, hasResolvedNavigationMenus]);
|
|
147
|
+
(0, _element.useEffect)(() => {
|
|
148
|
+
if (isLoadingInnerBlocks) {
|
|
149
|
+
(0, _a11y.speak)('Loading Navigation sidebar selected menu items.');
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (hasLoadedInnerBlocks) {
|
|
153
|
+
(0, _a11y.speak)('Navigation sidebar selected menu items have loaded.');
|
|
154
|
+
}
|
|
155
|
+
}, [isLoadingInnerBlocks, hasLoadedInnerBlocks]);
|
|
156
|
+
return (0, _element.createElement)("div", {
|
|
157
|
+
className: "edit-site-navigation-inspector"
|
|
158
|
+
}, hasResolvedNavigationMenus && !hasNavigationMenus && (0, _element.createElement)("p", {
|
|
159
|
+
className: "edit-site-navigation-inspector__empty-msg"
|
|
160
|
+
}, (0, _i18n.__)('There are no Navigation Menus.')), !hasResolvedNavigationMenus && (0, _element.createElement)("div", {
|
|
161
|
+
className: "edit-site-navigation-inspector__placeholder"
|
|
162
|
+
}), hasResolvedNavigationMenus && hasMoreThanOneNavigationMenu && (0, _element.createElement)(_components.SelectControl, {
|
|
163
|
+
"aria-controls": // aria-controls should only apply when referenced element is in DOM
|
|
164
|
+
hasLoadedInnerBlocks ? navMenuListId : undefined,
|
|
165
|
+
value: currentMenuId || defaultNavigationMenuId,
|
|
166
|
+
options: options,
|
|
167
|
+
onChange: newMenuId => setCurrentMenuId(Number(newMenuId))
|
|
168
|
+
}), isLoading && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)("div", {
|
|
169
|
+
className: "edit-site-navigation-inspector__placeholder is-child"
|
|
170
|
+
}), (0, _element.createElement)("div", {
|
|
171
|
+
className: "edit-site-navigation-inspector__placeholder is-child"
|
|
172
|
+
}), (0, _element.createElement)("div", {
|
|
173
|
+
className: "edit-site-navigation-inspector__placeholder is-child"
|
|
174
|
+
})), hasInnerBlocks && !isLoading && (0, _element.createElement)(_blockEditor.BlockEditorProvider, {
|
|
175
|
+
value: publishedInnerBlocks,
|
|
176
|
+
onChange: onChange,
|
|
177
|
+
onInput: onInput
|
|
178
|
+
}, (0, _element.createElement)(_navigationMenu.default, {
|
|
179
|
+
id: navMenuListId,
|
|
180
|
+
innerBlocks: publishedInnerBlocks
|
|
181
|
+
})), !hasInnerBlocks && !isLoading && (0, _element.createElement)("p", {
|
|
182
|
+
className: "edit-site-navigation-inspector__empty-msg"
|
|
183
|
+
}, (0, _i18n.__)('Navigation Menu is empty.')));
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=navigation-inspector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/navigation-menu-sidebar/navigation-inspector.js"],"names":["NAVIGATION_MENUS_QUERY","per_page","status","NavigationInspector","selectedNavigationBlockId","clientIdToRef","navigationMenus","isResolvingNavigationMenus","hasResolvedNavigationMenus","firstNavigationBlockId","select","__experimentalGetActiveBlockIdByBlockNames","__experimentalGetGlobalBlocksByName","getBlock","blockEditorStore","getEntityRecords","hasFinishedResolution","isResolving","coreStore","navigationMenusQuery","selectedNavId","navBlockIds","idToRef","forEach","id","attributes","ref","navMenuListId","NavigationMenu","firstNavRefInTemplate","firstNavigationMenuRef","defaultNavigationMenuId","currentMenuId","setCurrentMenuId","options","map","title","value","label","rendered","innerBlocks","onInput","onChange","isLoadingInnerBlocks","hasLoadedInnerBlocks","isLoading","hasMoreThanOneNavigationMenu","length","hasNavigationMenus","publishedInnerBlocks","hasInnerBlocks","undefined","newMenuId","Number"],"mappings":";;;;;;;;;AAIA;;AADA;;AAEA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AAKA;;AAlBA;AACA;AACA;;AAaA;AACA;AACA;AAGA,MAAMA,sBAAsB,GAAG,CAAE;AAAEC,EAAAA,QAAQ,EAAE,CAAC,CAAb;AAAgBC,EAAAA,MAAM,EAAE;AAAxB,CAAF,CAA/B;;AAEe,SAASC,mBAAT,GAA+B;AAAA;;AAC7C,QAAM;AACLC,IAAAA,yBADK;AAELC,IAAA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;AAAG,IAAA,SAAS,EAAC;AAAb,KACG,cAAI,gCAAJ,CADH,CAFF,EAOG,CAAExC,0BAAF,IACD;AAAK,IAAA,SAAS,EAAC;AAAf,IARF,EAUGA,0BAA0B,IAAIsC,4BAA9B,IACD,4BAAC,yBAAD;AACC,qBACC;AACAF,IAAAA,oBAAoB,GAAGjB,aAAH,GAAmBwB,SAHzC;AAKC,IAAA,KAAK,EAAGnB,aAAa,IAAID,uBAL1B;AAMC,IAAA,OAAO,EAAGG,OANX;AAOC,IAAA,QAAQ,EAAKkB,SAAF,IACVnB,gBAAgB,CAAEoB,MAAM,CAAED,SAAF,CAAR;AARlB,IAXF,EAuBGP,SAAS,IACV,qDACC;AAAK,IAAA,SAAS,EAAC;AAAf,IADD,EAEC;AAAK,IAAA,SAAS,EAAC;AAAf,IAFD,EAGC;AAAK,IAAA,SAAS,EAAC;AAAf,IAHD,CAxBF,EA8BGK,cAAc,IAAI,CAAEL,SAApB,IACD,4BAAC,gCAAD;AACC,IAAA,KAAK,EAAGI,oBADT;AAEC,IAAA,QAAQ,EAAGP,QAFZ;AAGC,IAAA,OAAO,EAAGD;AAHX,KAKC,4BAAC,uBAAD;AACC,IAAA,EAAE,EAAGd,aADN;AAEC,IAAA,WAAW,EAAGsB;AAFf,IALD,CA/BF,EA2CG,CAAEC,cAAF,IAAoB,CAAEL,SAAtB,IACD;AAAG,IAAA,SAAS,EAAC;AAAb,KACG,cAAI,2BAAJ,CADH,CA5CF,CADD;AAmDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useState, useEffect } from '@wordpress/element';\nimport { SelectControl } from '@wordpress/components';\nimport { store as coreStore, useEntityBlockEditor } from '@wordpress/core-data';\nimport {\n\tstore as blockEditorStore,\n\tBlockEditorProvider,\n} from '@wordpress/block-editor';\nimport { speak } from '@wordpress/a11y';\nimport { useInstanceId } from '@wordpress/compose';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport NavigationMenu from './navigation-menu';\n\nconst NAVIGATION_MENUS_QUERY = [ { per_page: -1, status: 'publish' } ];\n\nexport default function NavigationInspector() {\n\tconst {\n\t\tselectedNavigationBlockId,\n\t\tclientIdToRef,\n\t\tnavigationMenus,\n\t\tisResolvingNavigationMenus,\n\t\thasResolvedNavigationMenus,\n\t\tfirstNavigationBlockId,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\t__experimentalGetActiveBlockIdByBlockNames,\n\t\t\t__experimentalGetGlobalBlocksByName,\n\t\t\tgetBlock,\n\t\t} = select( blockEditorStore );\n\n\t\tconst { getEntityRecords, hasFinishedResolution, isResolving } = select(\n\t\t\tcoreStore\n\t\t);\n\n\t\tconst navigationMenusQuery = [\n\t\t\t'postType',\n\t\t\t'wp_navigation',\n\t\t\tNAVIGATION_MENUS_QUERY[ 0 ],\n\t\t];\n\n\t\t// Get the active Navigation block (if present).\n\t\tconst selectedNavId = __experimentalGetActiveBlockIdByBlockNames(\n\t\t\t'core/navigation'\n\t\t);\n\n\t\t// Get all Navigation blocks currently within the editor canvas.\n\t\tconst navBlockIds = __experimentalGetGlobalBlocksByName(\n\t\t\t'core/navigation'\n\t\t);\n\t\tconst idToRef = {};\n\t\tnavBlockIds.forEach( ( id ) => {\n\t\t\tidToRef[ id ] = getBlock( id )?.attributes?.ref;\n\t\t} );\n\t\treturn {\n\t\t\tselectedNavigationBlockId: selectedNavId,\n\t\t\tfirstNavigationBlockId: navBlockIds?.[ 0 ],\n\t\t\tclientIdToRef: idToRef,\n\t\t\tnavigationMenus: getEntityRecords( ...navigationMenusQuery ),\n\t\t\tisResolvingNavigationMenus: isResolving(\n\t\t\t\t'getEntityRecords',\n\t\t\t\tnavigationMenusQuery\n\t\t\t),\n\t\t\thasResolvedNavigationMenus: hasFinishedResolution(\n\t\t\t\t'getEntityRecords',\n\t\t\t\tnavigationMenusQuery\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tconst navMenuListId = useInstanceId(\n\t\tNavigationMenu,\n\t\t'edit-site-navigation-inspector-menu'\n\t);\n\n\tconst firstNavRefInTemplate = clientIdToRef[ firstNavigationBlockId ];\n\tconst firstNavigationMenuRef = navigationMenus?.[ 0 ]?.id;\n\n\t// Default Navigation Menu is either:\n\t// - the Navigation Menu referenced by the first Nav block within the template.\n\t// - the first of the available Navigation Menus (`wp_navigation`) posts.\n\tconst defaultNavigationMenuId =\n\t\tfirstNavRefInTemplate || firstNavigationMenuRef;\n\n\t// The Navigation Menu manually selected by the user within the Nav inspector.\n\tconst [ currentMenuId, setCurrentMenuId ] = useState(\n\t\tfirstNavRefInTemplate\n\t);\n\n\t// If a Nav block is selected within the canvas then set the\n\t// Navigation Menu referenced by it's `ref` attribute to be\n\t// active within the Navigation sidebar.\n\tuseEffect( () => {\n\t\tif ( selectedNavigationBlockId ) {\n\t\t\tsetCurrentMenuId( clientIdToRef[ selectedNavigationBlockId ] );\n\t\t}\n\t}, [ selectedNavigationBlockId ] );\n\n\tlet options = [];\n\tif ( navigationMenus ) {\n\t\toptions = navigationMenus.map( ( { id, title } ) => ( {\n\t\t\tvalue: id,\n\t\t\tlabel: title.rendered,\n\t\t} ) );\n\t}\n\n\tconst [ innerBlocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\t'wp_navigation',\n\t\t{ id: currentMenuId || defaultNavigationMenuId }\n\t);\n\n\tconst { isLoadingInnerBlocks, hasLoadedInnerBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isResolving, hasFinishedResolution } = select( coreStore );\n\t\t\treturn {\n\t\t\t\tisLoadingInnerBlocks: isResolving( 'getEntityRecord', [\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_navigation',\n\t\t\t\t\tcurrentMenuId || defaultNavigationMenuId,\n\t\t\t\t] ),\n\t\t\t\thasLoadedInnerBlocks: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecord',\n\t\t\t\t\t[\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'wp_navigation',\n\t\t\t\t\t\tcurrentMenuId || defaultNavigationMenuId,\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ currentMenuId, defaultNavigationMenuId ]\n\t);\n\n\tconst isLoading = ! ( hasResolvedNavigationMenus && hasLoadedInnerBlocks );\n\n\tconst hasMoreThanOneNavigationMenu = navigationMenus?.length > 1;\n\n\tconst hasNavigationMenus = !! navigationMenus?.length;\n\n\t// Entity block editor will return entities that are not currently published.\n\t// Guard by only allowing their usage if there are published Nav Menus.\n\tconst publishedInnerBlocks = hasNavigationMenus ? innerBlocks : [];\n\n\tconst hasInnerBlocks = !! publishedInnerBlocks?.length;\n\n\tuseEffect( () => {\n\t\tif ( isResolvingNavigationMenus ) {\n\t\t\tspeak( 'Loading Navigation sidebar menus.' );\n\t\t}\n\n\t\tif ( hasResolvedNavigationMenus ) {\n\t\t\tspeak( 'Navigation sidebar menus have loaded.' );\n\t\t}\n\t}, [ isResolvingNavigationMenus, hasResolvedNavigationMenus ] );\n\n\tuseEffect( () => {\n\t\tif ( isLoadingInnerBlocks ) {\n\t\t\tspeak( 'Loading Navigation sidebar selected menu items.' );\n\t\t}\n\n\t\tif ( hasLoadedInnerBlocks ) {\n\t\t\tspeak( 'Navigation sidebar selected menu items have loaded.' );\n\t\t}\n\t}, [ isLoadingInnerBlocks, hasLoadedInnerBlocks ] );\n\n\treturn (\n\t\t<div className=\"edit-site-navigation-inspector\">\n\t\t\t{ hasResolvedNavigationMenus && ! hasNavigationMenus && (\n\t\t\t\t<p className=\"edit-site-navigation-inspector__empty-msg\">\n\t\t\t\t\t{ __( 'There are no Navigation Menus.' ) }\n\t\t\t\t</p>\n\t\t\t) }\n\n\t\t\t{ ! hasResolvedNavigationMenus && (\n\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder\" />\n\t\t\t) }\n\t\t\t{ hasResolvedNavigationMenus && hasMoreThanOneNavigationMenu && (\n\t\t\t\t<SelectControl\n\t\t\t\t\taria-controls={\n\t\t\t\t\t\t// aria-controls should only apply when referenced element is in DOM\n\t\t\t\t\t\thasLoadedInnerBlocks ? navMenuListId : undefined\n\t\t\t\t\t}\n\t\t\t\t\tvalue={ currentMenuId || defaultNavigationMenuId }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tonChange={ ( newMenuId ) =>\n\t\t\t\t\t\tsetCurrentMenuId( Number( newMenuId ) )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isLoading && (\n\t\t\t\t<>\n\t\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder is-child\" />\n\t\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder is-child\" />\n\t\t\t\t\t<div className=\"edit-site-navigation-inspector__placeholder is-child\" />\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ hasInnerBlocks && ! isLoading && (\n\t\t\t\t<BlockEditorProvider\n\t\t\t\t\tvalue={ publishedInnerBlocks }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tonInput={ onInput }\n\t\t\t\t>\n\t\t\t\t\t<NavigationMenu\n\t\t\t\t\t\tid={ navMenuListId }\n\t\t\t\t\t\tinnerBlocks={ publishedInnerBlocks }\n\t\t\t\t\t/>\n\t\t\t\t</BlockEditorProvider>\n\t\t\t) }\n\n\t\t\t{ ! hasInnerBlocks && ! isLoading && (\n\t\t\t\t<p className=\"edit-site-navigation-inspector__empty-msg\">\n\t\t\t\t\t{ __( 'Navigation Menu is empty.' ) }\n\t\t\t\t</p>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = NavigationMenu;
|
|
7
|
+
|
|
8
|
+
var _element = require("@wordpress/element");
|
|
9
|
+
|
|
10
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
11
|
+
|
|
12
|
+
var _data = require("@wordpress/data");
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* WordPress dependencies
|
|
16
|
+
*/
|
|
17
|
+
const ALLOWED_BLOCKS = {
|
|
18
|
+
'core/navigation': ['core/navigation-link', 'core/search', 'core/social-links', 'core/page-list', 'core/spacer', 'core/home-link', 'core/site-title', 'core/site-logo', 'core/navigation-submenu'],
|
|
19
|
+
'core/social-links': ['core/social-link'],
|
|
20
|
+
'core/navigation-submenu': ['core/navigation-link', 'core/navigation-submenu'],
|
|
21
|
+
'core/navigation-link': ['core/navigation-link', 'core/navigation-submenu']
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function NavigationMenu(_ref) {
|
|
25
|
+
let {
|
|
26
|
+
innerBlocks,
|
|
27
|
+
id
|
|
28
|
+
} = _ref;
|
|
29
|
+
const {
|
|
30
|
+
updateBlockListSettings
|
|
31
|
+
} = (0, _data.useDispatch)(_blockEditor.store); //TODO: Block settings are normally updated as a side effect of rendering InnerBlocks in BlockList
|
|
32
|
+
//Think through a better way of doing this, possible with adding allowed blocks to block library metadata
|
|
33
|
+
|
|
34
|
+
(0, _element.useEffect)(() => {
|
|
35
|
+
updateBlockListSettings('', {
|
|
36
|
+
allowedBlocks: ALLOWED_BLOCKS['core/navigation']
|
|
37
|
+
});
|
|
38
|
+
innerBlocks.forEach(block => {
|
|
39
|
+
if (ALLOWED_BLOCKS[block.name]) {
|
|
40
|
+
updateBlockListSettings(block.clientId, {
|
|
41
|
+
allowedBlocks: ALLOWED_BLOCKS[block.name]
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}, [updateBlockListSettings, innerBlocks]);
|
|
46
|
+
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_blockEditor.__experimentalListView, {
|
|
47
|
+
id: id,
|
|
48
|
+
showNestedBlocks: true,
|
|
49
|
+
expandNested: false,
|
|
50
|
+
__experimentalFeatures: true,
|
|
51
|
+
__experimentalPersistentListViewFeatures: true
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=navigation-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/sidebar/navigation-menu-sidebar/navigation-menu.js"],"names":["ALLOWED_BLOCKS","NavigationMenu","innerBlocks","id","updateBlockListSettings","blockEditorStore","allowedBlocks","forEach","block","name","clientId"],"mappings":";;;;;;;AAOA;;AAJA;;AAKA;;AARA;AACA;AACA;AAQA,MAAMA,cAAc,GAAG;AACtB,qBAAmB,CAClB,sBADkB,EAElB,aAFkB,EAGlB,mBAHkB,EAIlB,gBAJkB,EAKlB,aALkB,EAMlB,gBANkB,EAOlB,iBAPkB,EAQlB,gBARkB,EASlB,yBATkB,CADG;AAYtB,uBAAqB,CAAE,kBAAF,CAZC;AAatB,6BAA2B,CAC1B,sBAD0B,EAE1B,yBAF0B,CAbL;AAiBtB,0BAAwB,CACvB,sBADuB,EAEvB,yBAFuB;AAjBF,CAAvB;;AAuBe,SAASC,cAAT,OAA+C;AAAA,MAAtB;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,GAAsB;AAC7D,QAAM;AAAEC,IAAAA;AAAF,MAA8B,uBAAaC,kBAAb,CAApC,CAD6D,CAG7D;AACA;;AACA,0BAAW,MAAM;AAChBD,IAAAA,uBAAuB,CAAE,EAAF,EAAM;AAC5BE,MAAAA,aAAa,EAAEN,cAAc,CAAE,iBAAF;AADD,KAAN,CAAvB;AAGAE,IAAAA,WAAW,CAACK,OAAZ,CAAuBC,KAAF,IAAa;AACjC,UAAKR,cAAc,CAAEQ,KAAK,CAACC,IAAR,CAAnB,EAAoC;AACnCL,QAAAA,uBAAuB,CAAEI,KAAK,CAACE,QAAR,EAAkB;AACxCJ,UAAAA,aAAa,EAAEN,cAAc,CAAEQ,KAAK,CAACC,IAAR;AADW,SAAlB,CAAvB;AAGA;AACD,KAND;AAOA,GAXD,EAWG,CAAEL,uBAAF,EAA2BF,WAA3B,CAXH;AAYA,SACC,qDACC,4BAAC,mCAAD;AACC,IAAA,EAAE,EAAGC,EADN;AAEC,IAAA,gBAAgB,MAFjB;AAGC,IAAA,YAAY,EAAG,KAHhB;AAIC,IAAA,sBAAsB,MAJvB;AAKC,IAAA,wCAAwC;AALzC,IADD,CADD;AAWA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalListView as ListView,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\n\nconst ALLOWED_BLOCKS = {\n\t'core/navigation': [\n\t\t'core/navigation-link',\n\t\t'core/search',\n\t\t'core/social-links',\n\t\t'core/page-list',\n\t\t'core/spacer',\n\t\t'core/home-link',\n\t\t'core/site-title',\n\t\t'core/site-logo',\n\t\t'core/navigation-submenu',\n\t],\n\t'core/social-links': [ 'core/social-link' ],\n\t'core/navigation-submenu': [\n\t\t'core/navigation-link',\n\t\t'core/navigation-submenu',\n\t],\n\t'core/navigation-link': [\n\t\t'core/navigation-link',\n\t\t'core/navigation-submenu',\n\t],\n};\n\nexport default function NavigationMenu( { innerBlocks, id } ) {\n\tconst { updateBlockListSettings } = useDispatch( blockEditorStore );\n\n\t//TODO: Block settings are normally updated as a side effect of rendering InnerBlocks in BlockList\n\t//Think through a better way of doing this, possible with adding allowed blocks to block library metadata\n\tuseEffect( () => {\n\t\tupdateBlockListSettings( '', {\n\t\t\tallowedBlocks: ALLOWED_BLOCKS[ 'core/navigation' ],\n\t\t} );\n\t\tinnerBlocks.forEach( ( block ) => {\n\t\t\tif ( ALLOWED_BLOCKS[ block.name ] ) {\n\t\t\t\tupdateBlockListSettings( block.clientId, {\n\t\t\t\t\tallowedBlocks: ALLOWED_BLOCKS[ block.name ],\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t}, [ updateBlockListSettings, innerBlocks ] );\n\treturn (\n\t\t<>\n\t\t\t<ListView\n\t\t\t\tid={ id }\n\t\t\t\tshowNestedBlocks\n\t\t\t\texpandNested={ false }\n\t\t\t\t__experimentalFeatures\n\t\t\t\t__experimentalPersistentListViewFeatures\n\t\t\t/>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -28,6 +28,12 @@ function ConvertToRegularBlocks(_ref) {
|
|
|
28
28
|
const {
|
|
29
29
|
replaceBlocks
|
|
30
30
|
} = (0, _data.useDispatch)(_blockEditor.store);
|
|
31
|
+
const canRemove = (0, _data.useSelect)(select => select(_blockEditor.store).canRemoveBlock(clientId), [clientId]);
|
|
32
|
+
|
|
33
|
+
if (!canRemove) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
31
37
|
return (0, _element.createElement)(_blockEditor.BlockSettingsMenuControls, null, _ref2 => {
|
|
32
38
|
let {
|
|
33
39
|
onClose
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/template-part-converter/convert-to-regular.js"],"names":["ConvertToRegularBlocks","clientId","getBlocks","blockEditorStore","replaceBlocks","onClose"],"mappings":";;;;;;;;;AAGA;;AACA;;AAIA;;AACA;;AATA;AACA;AACA;AASe,SAASA,sBAAT,OAAgD;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AAC9D,QAAM;AAAEC,IAAAA;AAAF,MAAgB,qBAAWC,kBAAX,CAAtB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAoB,uBAAaD,kBAAb,CAA1B;AAEA,SACC,4BAAC,sCAAD,QACG;AAAA,QAAE;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/template-part-converter/convert-to-regular.js"],"names":["ConvertToRegularBlocks","clientId","getBlocks","blockEditorStore","replaceBlocks","canRemove","select","canRemoveBlock","onClose"],"mappings":";;;;;;;;;AAGA;;AACA;;AAIA;;AACA;;AATA;AACA;AACA;AASe,SAASA,sBAAT,OAAgD;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AAC9D,QAAM;AAAEC,IAAAA;AAAF,MAAgB,qBAAWC,kBAAX,CAAtB;AACA,QAAM;AAAEC,IAAAA;AAAF,MAAoB,uBAAaD,kBAAb,CAA1B;AAEA,QAAME,SAAS,GAAG,qBACfC,MAAF,IAAcA,MAAM,CAAEH,kBAAF,CAAN,CAA2BI,cAA3B,CAA2CN,QAA3C,CADG,EAEjB,CAAEA,QAAF,CAFiB,CAAlB;;AAKA,MAAK,CAAEI,SAAP,EAAmB;AAClB,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,sCAAD,QACG;AAAA,QAAE;AAAEG,MAAAA;AAAF,KAAF;AAAA,WACD,4BAAC,oBAAD;AACC,MAAA,OAAO,EAAG,MAAM;AACfJ,QAAAA,aAAa,CAAEH,QAAF,EAAYC,SAAS,CAAED,QAAF,CAArB,CAAb;AACAO,QAAAA,OAAO;AACP;AAJF,OAMG,cAAI,kCAAJ,CANH,CADC;AAAA,GADH,CADD;AAcA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tBlockSettingsMenuControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\nexport default function ConvertToRegularBlocks( { clientId } ) {\n\tconst { getBlocks } = useSelect( blockEditorStore );\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\n\tconst canRemove = useSelect(\n\t\t( select ) => select( blockEditorStore ).canRemoveBlock( clientId ),\n\t\t[ clientId ]\n\t);\n\n\tif ( ! canRemove ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\treplaceBlocks( clientId, getBlocks( clientId ) );\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Detach blocks from template part' ) }\n\t\t\t\t</MenuItem>\n\t\t\t) }\n\t\t</BlockSettingsMenuControls>\n\t);\n}\n"]}
|
package/build/index.js
CHANGED
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/index.js"],"names":["reinitializeEditor","target","settings","__unstableHomeTemplate","reboot","bind","preferencesStore","setDefaults","editorMode","fixedToolbar","focusMode","welcomeGuide","welcomeGuideStyles","editSiteStore","updateSettings","editorStore","updateEditorSettings","defaultTemplateTypes","defaultTemplatePartAreas","isLandingOnListPage","window","location","href","setIsNavigationPanelOpened","viewportStore","isViewportMatch","initializeEditor","id","__experimentalFetchLinkSuggestions","search","searchOptions","__experimentalFetchRichUrlData","fetchUrlData","__experimentalSpotlightEntityBlocks","document","getElementById","blocksStore","__experimentalReapplyBlockTypeFilters","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA;;AANA;;AACA;;AAIA;;AAEA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/index.js"],"names":["reinitializeEditor","target","settings","__unstableHomeTemplate","reboot","bind","preferencesStore","setDefaults","editorMode","fixedToolbar","focusMode","keepCaretInsideBlock","welcomeGuide","welcomeGuideStyles","editSiteStore","updateSettings","editorStore","updateEditorSettings","defaultTemplateTypes","defaultTemplatePartAreas","isLandingOnListPage","window","location","href","setIsNavigationPanelOpened","viewportStore","isViewportMatch","initializeEditor","id","__experimentalFetchLinkSuggestions","search","searchOptions","__experimentalFetchRichUrlData","fetchUrlData","__experimentalSpotlightEntityBlocks","document","getElementById","blocksStore","__experimentalReapplyBlockTypeFilters","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA;;AANA;;AACA;;AA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,0BAAUN,YAAV,EAA0BU,0BAA1B,CACC,kBAAQC,eAAR,EAAwBC,eAAxB,CAAyC,QAAzC,CADD;AAGA;AACD;AAED,uBAAQ,4BAAC,YAAD;AAAa,IAAA,MAAM,EAAGtB;AAAtB,IAAR,EAA2CH,MAA3C;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAAS0B,gBAAT,CAA2BC,EAA3B,EAA+B1B,QAA/B,EAA0C;AAChDA,EAAAA,QAAQ,CAAC2B,kCAAT,GAA8C,CAAEC,MAAF,EAAUC,aAAV,KAC7C,kDAAsBD,MAAtB,EAA8BC,aAA9B,EAA6C7B,QAA7C,CADD;;AAEAA,EAAAA,QAAQ,CAAC8B,8BAAT,GAA0CC,oCAA1C;AACA/B,EAAAA,QAAQ,CAACgC,mCAAT,GAA+C,CAAE,oBAAF,CAA/C;AAEA,QAAMjC,MAAM,GAAGkC,QAAQ,CAACC,cAAT,CAAyBR,EAAzB,CAAf;;AAEA,sBAAUS,aAAV,EAAwBC,qCAAxB;;AACA;;AACA,MAAKC,OAAO,CAACC,GAAR,CAAYC,mBAAjB,EAAuC;AACtC,oEAA8C;AAC7CC,MAAAA,eAAe,EAAE;AAD4B,KAA9C;AAGA;;AAED1C,EAAAA,kBAAkB,CAAEC,MAAF,EAAUC,QAAV,CAAlB;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { dispatch, select } from '@wordpress/data';\nimport { render, unmountComponentAtNode } from '@wordpress/element';\nimport {\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n} from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { __ } from '@wordpress/i18n';\nimport { store as viewportStore } from '@wordpress/viewport';\nimport { getQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport { store as editSiteStore } from './store';\nimport EditSiteApp from './components/app';\nimport getIsListPage from './utils/get-is-list-page';\nimport ErrorBoundaryWarning from './components/error-boundary/warning';\n\n/**\n * Reinitializes the editor after the user chooses to reboot the editor after\n * an unhandled error occurs, replacing previously mounted editor element using\n * an initial state from prior to the crash.\n *\n * @param {Element} target DOM node in which editor is rendered.\n * @param {?Object} settings Editor settings object.\n */\nexport function reinitializeEditor( target, settings ) {\n\t// Display warning if editor wasn't able to resolve homepage template.\n\tif ( ! settings.__unstableHomeTemplate ) {\n\t\trender(\n\t\t\t<ErrorBoundaryWarning\n\t\t\t\tmessage={ __(\n\t\t\t\t\t'The editor is unable to find a block template for the homepage.'\n\t\t\t\t) }\n\t\t\t\tdashboardLink=\"index.php\"\n\t\t\t/>,\n\t\t\ttarget\n\t\t);\n\t\treturn;\n\t}\n\n\t// This will be a no-op if the target doesn't have any React nodes.\n\tunmountComponentAtNode( target );\n\tconst reboot = reinitializeEditor.bind( null, target, settings );\n\n\t// We dispatch actions and update the store synchronously before rendering\n\t// so that we won't trigger unnecessary re-renders with useEffect.\n\t{\n\t\tdispatch( preferencesStore ).setDefaults( 'core/edit-site', {\n\t\t\teditorMode: 'visual',\n\t\t\tfixedToolbar: false,\n\t\t\tfocusMode: false,\n\t\t\tkeepCaretInsideBlock: false,\n\t\t\twelcomeGuide: true,\n\t\t\twelcomeGuideStyles: true,\n\t\t} );\n\n\t\tdispatch( editSiteStore ).updateSettings( settings );\n\n\t\t// Keep the defaultTemplateTypes in the core/editor settings too,\n\t\t// so that they can be selected with core/editor selectors in any editor.\n\t\t// This is needed because edit-site doesn't initialize with EditorProvider,\n\t\t// which internally uses updateEditorSettings as well.\n\t\tdispatch( editorStore ).updateEditorSettings( {\n\t\t\tdefaultTemplateTypes: settings.defaultTemplateTypes,\n\t\t\tdefaultTemplatePartAreas: settings.defaultTemplatePartAreas,\n\t\t} );\n\n\t\tconst isLandingOnListPage = getIsListPage(\n\t\t\tgetQueryArgs( window.location.href )\n\t\t);\n\n\t\tif ( isLandingOnListPage ) {\n\t\t\t// Default the navigation panel to be opened when we're in a bigger\n\t\t\t// screen and land in the list screen.\n\t\t\tdispatch( editSiteStore ).setIsNavigationPanelOpened(\n\t\t\t\tselect( viewportStore ).isViewportMatch( 'medium' )\n\t\t\t);\n\t\t}\n\t}\n\n\trender( <EditSiteApp reboot={ reboot } />, target );\n}\n\n/**\n * Initializes the site editor screen.\n *\n * @param {string} id ID of the root element to render the screen in.\n * @param {Object} settings Editor settings.\n */\nexport function initializeEditor( id, settings ) {\n\tsettings.__experimentalFetchLinkSuggestions = ( search, searchOptions ) =>\n\t\tfetchLinkSuggestions( search, searchOptions, settings );\n\tsettings.__experimentalFetchRichUrlData = fetchUrlData;\n\tsettings.__experimentalSpotlightEntityBlocks = [ 'core/template-part' ];\n\n\tconst target = document.getElementById( id );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\tregisterCoreBlocks();\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: true,\n\t\t} );\n\t}\n\n\treinitializeEditor( target, settings );\n}\n\nexport { default as __experimentalMainDashboardButton } from './components/main-dashboard-button';\nexport { default as __experimentalNavigationToggle } from './components/navigation-sidebar/navigation-toggle';\nexport { default as PluginSidebar } from './components/sidebar/plugin-sidebar';\nexport { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';\nexport { default as PluginMoreMenuItem } from './components/header/plugin-more-menu-item';\n"]}
|
package/build/store/actions.js
CHANGED
|
@@ -386,16 +386,16 @@ const revertTemplate = function (template) {
|
|
|
386
386
|
try {
|
|
387
387
|
var _fileTemplate$content;
|
|
388
388
|
|
|
389
|
-
const
|
|
389
|
+
const templateEntityConfig = registry.select(_coreData.store).getEntityConfig('postType', template.type);
|
|
390
390
|
|
|
391
|
-
if (!
|
|
391
|
+
if (!templateEntityConfig) {
|
|
392
392
|
registry.dispatch(_notices.store).createErrorNotice((0, _i18n.__)('The editor has encountered an unexpected error. Please reload.'), {
|
|
393
393
|
type: 'snackbar'
|
|
394
394
|
});
|
|
395
395
|
return;
|
|
396
396
|
}
|
|
397
397
|
|
|
398
|
-
const fileTemplatePath = (0, _url.addQueryArgs)(`${
|
|
398
|
+
const fileTemplatePath = (0, _url.addQueryArgs)(`${templateEntityConfig.baseURL}/${template.id}`, {
|
|
399
399
|
context: 'edit',
|
|
400
400
|
source: 'theme'
|
|
401
401
|
});
|