@wordpress/editor 14.7.1-next.1f6eadc42.0 → 14.8.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 +2 -0
- package/README.md +1 -1
- package/build/bindings/post-meta.js +42 -7
- package/build/bindings/post-meta.js.map +1 -1
- package/build/components/block-manager/index.js +43 -62
- package/build/components/block-manager/index.js.map +1 -1
- package/build/components/document-bar/index.js +20 -28
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/editor-interface/index.js +1 -2
- package/build/components/editor-interface/index.js.map +1 -1
- package/build/components/global-styles-provider/index.js +21 -12
- package/build/components/global-styles-provider/index.js.map +1 -1
- package/build/components/header/index.js +3 -5
- package/build/components/header/index.js.map +1 -1
- package/build/components/media-categories/index.js +1 -0
- package/build/components/media-categories/index.js.map +1 -1
- package/build/components/post-status/index.js +1 -0
- package/build/components/post-status/index.js.map +1 -1
- package/build/components/post-taxonomies/hierarchical-term-selector.js +2 -4
- package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build/components/post-taxonomies/most-used-terms.js +2 -4
- package/build/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build/components/post-url/index.js +8 -7
- package/build/components/post-url/index.js.map +1 -1
- package/build/components/save-publish-panels/index.js +4 -10
- package/build/components/save-publish-panels/index.js.map +1 -1
- package/build-module/bindings/post-meta.js +40 -7
- package/build-module/bindings/post-meta.js.map +1 -1
- package/build-module/components/block-manager/index.js +44 -63
- package/build-module/components/block-manager/index.js.map +1 -1
- package/build-module/components/document-bar/index.js +22 -28
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/editor-interface/index.js +1 -2
- package/build-module/components/editor-interface/index.js.map +1 -1
- package/build-module/components/global-styles-provider/index.js +21 -12
- package/build-module/components/global-styles-provider/index.js.map +1 -1
- package/build-module/components/header/index.js +3 -5
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/media-categories/index.js +1 -0
- package/build-module/components/media-categories/index.js.map +1 -1
- package/build-module/components/post-status/index.js +1 -0
- package/build-module/components/post-status/index.js.map +1 -1
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js +2 -4
- package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
- package/build-module/components/post-taxonomies/most-used-terms.js +2 -4
- package/build-module/components/post-taxonomies/most-used-terms.js.map +1 -1
- package/build-module/components/post-url/index.js +9 -8
- package/build-module/components/post-url/index.js.map +1 -1
- package/build-module/components/save-publish-panels/index.js +4 -10
- package/build-module/components/save-publish-panels/index.js.map +1 -1
- package/build-style/style-rtl.css +37 -18
- package/build-style/style.css +37 -18
- package/build-types/bindings/post-meta.d.ts +4 -1
- package/build-types/bindings/post-meta.d.ts.map +1 -1
- package/build-types/components/block-manager/index.d.ts +1 -2
- package/build-types/components/block-manager/index.d.ts.map +1 -1
- package/build-types/components/document-bar/index.d.ts +7 -6
- package/build-types/components/document-bar/index.d.ts.map +1 -1
- package/build-types/components/editor-interface/index.d.ts +1 -2
- package/build-types/components/editor-interface/index.d.ts.map +1 -1
- package/build-types/components/global-styles-provider/index.d.ts.map +1 -1
- package/build-types/components/header/index.d.ts +2 -2
- package/build-types/components/header/index.d.ts.map +1 -1
- package/build-types/components/post-status/index.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/most-used-terms.d.ts.map +1 -1
- package/build-types/components/post-url/index.d.ts.map +1 -1
- package/build-types/components/save-publish-panels/index.d.ts.map +1 -1
- package/package.json +36 -36
- package/src/bindings/post-meta.js +56 -20
- package/src/components/block-manager/index.js +49 -65
- package/src/components/document-bar/index.js +29 -41
- package/src/components/document-bar/style.scss +33 -15
- package/src/components/editor-interface/index.js +1 -2
- package/src/components/global-styles-provider/index.js +50 -36
- package/src/components/header/index.js +3 -6
- package/src/components/post-panel-row/style.scss +1 -0
- package/src/components/post-status/index.js +1 -0
- package/src/components/post-status/style.scss +5 -0
- package/src/components/post-taxonomies/hierarchical-term-selector.js +1 -2
- package/src/components/post-taxonomies/most-used-terms.js +1 -2
- package/src/components/post-taxonomies/style.scss +0 -4
- package/src/components/post-url/index.js +9 -7
- package/src/components/save-publish-panels/index.js +2 -6
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -266,7 +266,7 @@ _Parameters_
|
|
|
266
266
|
|
|
267
267
|
- _props_ `Object`: The component props.
|
|
268
268
|
- _props.title_ `string`: A title for the document, defaulting to the document or template title currently being edited.
|
|
269
|
-
- _props.icon_ `
|
|
269
|
+
- _props.icon_ `IconType`: An icon for the document, no default. (A default icon indicating the document post type is no longer used.)
|
|
270
270
|
|
|
271
271
|
_Returns_
|
|
272
272
|
|
|
@@ -6,12 +6,33 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _coreData = require("@wordpress/core-data");
|
|
8
8
|
var _store = require("../store");
|
|
9
|
+
var _lockUnlock = require("../lock-unlock");
|
|
9
10
|
/**
|
|
10
11
|
* WordPress dependencies
|
|
11
12
|
*/
|
|
13
|
+
|
|
12
14
|
/**
|
|
13
15
|
* Internal dependencies
|
|
14
16
|
*/
|
|
17
|
+
|
|
18
|
+
function getMetadata(registry, context, registeredFields) {
|
|
19
|
+
let metaFields = {};
|
|
20
|
+
const type = registry.select(_store.store).getCurrentPostType();
|
|
21
|
+
const {
|
|
22
|
+
getEditedEntityRecord
|
|
23
|
+
} = registry.select(_coreData.store);
|
|
24
|
+
if (context?.postType && context?.postId) {
|
|
25
|
+
metaFields = getEditedEntityRecord('postType', context?.postType, context?.postId).meta;
|
|
26
|
+
} else if (type === 'wp_template') {
|
|
27
|
+
// Populate the `metaFields` object with the default values.
|
|
28
|
+
Object.entries(registeredFields || {}).forEach(([key, props]) => {
|
|
29
|
+
if (props.default) {
|
|
30
|
+
metaFields[key] = props.default;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return metaFields;
|
|
35
|
+
}
|
|
15
36
|
var _default = exports.default = {
|
|
16
37
|
name: 'core/post-meta',
|
|
17
38
|
getValues({
|
|
@@ -19,12 +40,17 @@ var _default = exports.default = {
|
|
|
19
40
|
context,
|
|
20
41
|
bindings
|
|
21
42
|
}) {
|
|
22
|
-
const
|
|
43
|
+
const {
|
|
44
|
+
getRegisteredPostMeta
|
|
45
|
+
} = (0, _lockUnlock.unlock)(registry.select(_coreData.store));
|
|
46
|
+
const registeredFields = getRegisteredPostMeta(context?.postType);
|
|
47
|
+
const metaFields = getMetadata(registry, context, registeredFields);
|
|
23
48
|
const newValues = {};
|
|
24
49
|
for (const [attributeName, source] of Object.entries(bindings)) {
|
|
25
|
-
var
|
|
26
|
-
// Use the
|
|
27
|
-
|
|
50
|
+
var _ref, _metaFields$metaKey;
|
|
51
|
+
// Use the value, the field label, or the field key.
|
|
52
|
+
const metaKey = source.args.key;
|
|
53
|
+
newValues[attributeName] = (_ref = (_metaFields$metaKey = metaFields?.[metaKey]) !== null && _metaFields$metaKey !== void 0 ? _metaFields$metaKey : registeredFields?.[metaKey]?.title) !== null && _ref !== void 0 ? _ref : metaKey;
|
|
28
54
|
}
|
|
29
55
|
return newValues;
|
|
30
56
|
},
|
|
@@ -87,13 +113,22 @@ var _default = exports.default = {
|
|
|
87
113
|
registry,
|
|
88
114
|
context
|
|
89
115
|
}) {
|
|
90
|
-
const
|
|
116
|
+
const {
|
|
117
|
+
getRegisteredPostMeta
|
|
118
|
+
} = (0, _lockUnlock.unlock)(registry.select(_coreData.store));
|
|
119
|
+
const registeredFields = getRegisteredPostMeta(context?.postType);
|
|
120
|
+
const metaFields = getMetadata(registry, context, registeredFields);
|
|
91
121
|
if (!metaFields || !Object.keys(metaFields).length) {
|
|
92
122
|
return null;
|
|
93
123
|
}
|
|
94
|
-
|
|
124
|
+
return Object.fromEntries(Object.entries(metaFields)
|
|
95
125
|
// Remove footnotes or private keys from the list of fields.
|
|
96
|
-
|
|
126
|
+
.filter(([key]) => key !== 'footnotes' && key.charAt(0) !== '_')
|
|
127
|
+
// Return object with label and value.
|
|
128
|
+
.map(([key, value]) => [key, {
|
|
129
|
+
label: registeredFields?.[key]?.title || key,
|
|
130
|
+
value
|
|
131
|
+
}]));
|
|
97
132
|
}
|
|
98
133
|
};
|
|
99
134
|
//# sourceMappingURL=post-meta.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_coreData","require","_store","
|
|
1
|
+
{"version":3,"names":["_coreData","require","_store","_lockUnlock","getMetadata","registry","context","registeredFields","metaFields","type","select","editorStore","getCurrentPostType","getEditedEntityRecord","coreDataStore","postType","postId","meta","Object","entries","forEach","key","props","default","_default","exports","name","getValues","bindings","getRegisteredPostMeta","unlock","newValues","attributeName","source","_ref","_metaFields$metaKey","metaKey","args","title","setValues","newMeta","values","newValue","dispatch","editEntityRecord","canUserEditValue","query","queryId","fieldValue","getEntityRecord","undefined","areCustomFieldsEnabled","getEditorSettings","enableCustomFields","canUserEdit","canUser","kind","id","getFieldsList","keys","length","fromEntries","filter","charAt","map","value","label"],"sources":["@wordpress/editor/src/bindings/post-meta.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nfunction getMetadata( registry, context, registeredFields ) {\n\tlet metaFields = {};\n\tconst type = registry.select( editorStore ).getCurrentPostType();\n\tconst { getEditedEntityRecord } = registry.select( coreDataStore );\n\n\tif ( context?.postType && context?.postId ) {\n\t\tmetaFields = getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\tcontext?.postType,\n\t\t\tcontext?.postId\n\t\t).meta;\n\t} else if ( type === 'wp_template' ) {\n\t\t// Populate the `metaFields` object with the default values.\n\t\tObject.entries( registeredFields || {} ).forEach(\n\t\t\t( [ key, props ] ) => {\n\t\t\t\tif ( props.default ) {\n\t\t\t\t\tmetaFields[ key ] = props.default;\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}\n\n\treturn metaFields;\n}\n\nexport default {\n\tname: 'core/post-meta',\n\tgetValues( { registry, context, bindings } ) {\n\t\tconst { getRegisteredPostMeta } = unlock(\n\t\t\tregistry.select( coreDataStore )\n\t\t);\n\t\tconst registeredFields = getRegisteredPostMeta( context?.postType );\n\t\tconst metaFields = getMetadata( registry, context, registeredFields );\n\n\t\tconst newValues = {};\n\t\tfor ( const [ attributeName, source ] of Object.entries( bindings ) ) {\n\t\t\t// Use the value, the field label, or the field key.\n\t\t\tconst metaKey = source.args.key;\n\t\t\tnewValues[ attributeName ] =\n\t\t\t\tmetaFields?.[ metaKey ] ??\n\t\t\t\tregisteredFields?.[ metaKey ]?.title ??\n\t\t\t\tmetaKey;\n\t\t}\n\t\treturn newValues;\n\t},\n\tsetValues( { registry, context, bindings } ) {\n\t\tconst newMeta = {};\n\t\tObject.values( bindings ).forEach( ( { args, newValue } ) => {\n\t\t\tnewMeta[ args.key ] = newValue;\n\t\t} );\n\t\tregistry\n\t\t\t.dispatch( coreDataStore )\n\t\t\t.editEntityRecord( 'postType', context?.postType, context?.postId, {\n\t\t\t\tmeta: newMeta,\n\t\t\t} );\n\t},\n\tcanUserEditValue( { select, context, args } ) {\n\t\t// Lock editing in query loop.\n\t\tif ( context?.query || context?.queryId ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst postType =\n\t\t\tcontext?.postType || select( editorStore ).getCurrentPostType();\n\n\t\t// Check that editing is happening in the post editor and not a template.\n\t\tif ( postType === 'wp_template' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check that the custom field is not protected and available in the REST API.\n\t\t// Empty string or `false` could be a valid value, so we need to check if the field value is undefined.\n\t\tconst fieldValue = select( coreDataStore ).getEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType,\n\t\t\tcontext?.postId\n\t\t)?.meta?.[ args.key ];\n\n\t\tif ( fieldValue === undefined ) {\n\t\t\treturn false;\n\t\t}\n\t\t// Check that custom fields metabox is not enabled.\n\t\tconst areCustomFieldsEnabled =\n\t\t\tselect( editorStore ).getEditorSettings().enableCustomFields;\n\t\tif ( areCustomFieldsEnabled ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check that the user has the capability to edit post meta.\n\t\tconst canUserEdit = select( coreDataStore ).canUser( 'update', {\n\t\t\tkind: 'postType',\n\t\t\tname: context?.postType,\n\t\t\tid: context?.postId,\n\t\t} );\n\t\tif ( ! canUserEdit ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t},\n\tgetFieldsList( { registry, context } ) {\n\t\tconst { getRegisteredPostMeta } = unlock(\n\t\t\tregistry.select( coreDataStore )\n\t\t);\n\t\tconst registeredFields = getRegisteredPostMeta( context?.postType );\n\t\tconst metaFields = getMetadata( registry, context, registeredFields );\n\n\t\tif ( ! metaFields || ! Object.keys( metaFields ).length ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn Object.fromEntries(\n\t\t\tObject.entries( metaFields )\n\t\t\t\t// Remove footnotes or private keys from the list of fields.\n\t\t\t\t.filter(\n\t\t\t\t\t( [ key ] ) =>\n\t\t\t\t\t\tkey !== 'footnotes' && key.charAt( 0 ) !== '_'\n\t\t\t\t)\n\t\t\t\t// Return object with label and value.\n\t\t\t\t.map( ( [ key, value ] ) => [\n\t\t\t\t\tkey,\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: registeredFields?.[ key ]?.title || key,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t},\n\t\t\t\t] )\n\t\t);\n\t},\n};\n"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA,SAASG,WAAWA,CAAEC,QAAQ,EAAEC,OAAO,EAAEC,gBAAgB,EAAG;EAC3D,IAAIC,UAAU,GAAG,CA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E,KACRA,GAAG,KAAK,WAAW,IAAIA,GAAG,CAAC0C,MAAM,CAAE,CAAE,CAAC,KAAK,GAC7C;IACA;IAAA,CACCC,GAAG,CAAE,CAAE,CAAE3C,GAAG,EAAE4C,KAAK,CAAE,KAAM,CAC3B5C,GAAG,EACH;MACC6C,KAAK,EAAE3D,gBAAgB,GAAIc,GAAG,CAAE,EAAEiB,KAAK,IAAIjB,GAAG;MAC9C4C;IACD,CAAC,CACA,CACJ,CAAC;EACF;AACD,CAAC","ignoreList":[]}
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.default =
|
|
7
|
+
exports.default = BlockManager;
|
|
8
8
|
var _blocks = require("@wordpress/blocks");
|
|
9
9
|
var _data = require("@wordpress/data");
|
|
10
10
|
var _components = require("@wordpress/components");
|
|
@@ -25,32 +25,55 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
25
25
|
* Internal dependencies
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
function BlockManager({
|
|
29
|
-
blockTypes,
|
|
30
|
-
categories,
|
|
31
|
-
hasBlockSupport,
|
|
32
|
-
isMatchingSearchTerm,
|
|
33
|
-
numberOfHiddenBlocks,
|
|
34
|
-
enableAllBlockTypes
|
|
35
|
-
}) {
|
|
28
|
+
function BlockManager() {
|
|
36
29
|
const debouncedSpeak = (0, _compose.useDebounce)(_a11y.speak, 500);
|
|
37
30
|
const [search, setSearch] = (0, _element.useState)('');
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
const {
|
|
32
|
+
showBlockTypes
|
|
33
|
+
} = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_store.store));
|
|
34
|
+
const {
|
|
35
|
+
blockTypes,
|
|
36
|
+
categories,
|
|
37
|
+
hasBlockSupport,
|
|
38
|
+
isMatchingSearchTerm,
|
|
39
|
+
numberOfHiddenBlocks
|
|
40
|
+
} = (0, _data.useSelect)(select => {
|
|
41
|
+
var _select$get;
|
|
42
|
+
// Some hidden blocks become unregistered
|
|
43
|
+
// by removing for instance the plugin that registered them, yet
|
|
44
|
+
// they're still remain as hidden by the user's action.
|
|
45
|
+
// We consider "hidden", blocks which were hidden and
|
|
46
|
+
// are still registered.
|
|
47
|
+
const _blockTypes = select(_blocks.store).getBlockTypes();
|
|
48
|
+
const hiddenBlockTypes = ((_select$get = select(_preferences.store).get('core', 'hiddenBlockTypes')) !== null && _select$get !== void 0 ? _select$get : []).filter(hiddenBlock => {
|
|
49
|
+
return _blockTypes.some(registeredBlock => registeredBlock.name === hiddenBlock);
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
blockTypes: _blockTypes,
|
|
53
|
+
categories: select(_blocks.store).getCategories(),
|
|
54
|
+
hasBlockSupport: select(_blocks.store).hasBlockSupport,
|
|
55
|
+
isMatchingSearchTerm: select(_blocks.store).isMatchingSearchTerm,
|
|
56
|
+
numberOfHiddenBlocks: Array.isArray(hiddenBlockTypes) && hiddenBlockTypes.length
|
|
57
|
+
};
|
|
58
|
+
}, []);
|
|
59
|
+
function enableAllBlockTypes(newBlockTypes) {
|
|
60
|
+
const blockNames = newBlockTypes.map(({
|
|
61
|
+
name
|
|
62
|
+
}) => name);
|
|
63
|
+
showBlockTypes(blockNames);
|
|
64
|
+
}
|
|
65
|
+
const filteredBlockTypes = blockTypes.filter(blockType => hasBlockSupport(blockType, 'inserter', true) && (!search || isMatchingSearchTerm(blockType, search)) && (!blockType.parent || blockType.parent.includes('core/post-content')));
|
|
43
66
|
|
|
44
67
|
// Announce search results on change
|
|
45
68
|
(0, _element.useEffect)(() => {
|
|
46
69
|
if (!search) {
|
|
47
70
|
return;
|
|
48
71
|
}
|
|
49
|
-
const count =
|
|
72
|
+
const count = filteredBlockTypes.length;
|
|
50
73
|
const resultsFoundMessage = (0, _i18n.sprintf)( /* translators: %d: number of results. */
|
|
51
74
|
(0, _i18n._n)('%d result found.', '%d results found.', count), count);
|
|
52
75
|
debouncedSpeak(resultsFoundMessage);
|
|
53
|
-
}, [
|
|
76
|
+
}, [filteredBlockTypes?.length, search, debouncedSpeak]);
|
|
54
77
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
55
78
|
className: "editor-block-manager__content",
|
|
56
79
|
children: [!!numberOfHiddenBlocks && /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
@@ -59,7 +82,7 @@ function BlockManager({
|
|
|
59
82
|
(0, _i18n._n)('%d block is hidden.', '%d blocks are hidden.', numberOfHiddenBlocks), numberOfHiddenBlocks), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
60
83
|
__next40pxDefaultSize: true,
|
|
61
84
|
variant: "link",
|
|
62
|
-
onClick: () => enableAllBlockTypes(
|
|
85
|
+
onClick: () => enableAllBlockTypes(filteredBlockTypes),
|
|
63
86
|
children: (0, _i18n.__)('Reset')
|
|
64
87
|
})]
|
|
65
88
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.SearchControl, {
|
|
@@ -74,61 +97,19 @@ function BlockManager({
|
|
|
74
97
|
role: "region",
|
|
75
98
|
"aria-label": (0, _i18n.__)('Available block types'),
|
|
76
99
|
className: "editor-block-manager__results",
|
|
77
|
-
children: [
|
|
100
|
+
children: [filteredBlockTypes.length === 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
|
|
78
101
|
className: "editor-block-manager__no-results",
|
|
79
102
|
children: (0, _i18n.__)('No blocks found.')
|
|
80
103
|
}), categories.map(category => /*#__PURE__*/(0, _jsxRuntime.jsx)(_category.default, {
|
|
81
104
|
title: category.title,
|
|
82
|
-
blockTypes:
|
|
105
|
+
blockTypes: filteredBlockTypes.filter(blockType => blockType.category === category.slug)
|
|
83
106
|
}, category.slug)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_category.default, {
|
|
84
107
|
title: (0, _i18n.__)('Uncategorized'),
|
|
85
|
-
blockTypes:
|
|
108
|
+
blockTypes: filteredBlockTypes.filter(({
|
|
86
109
|
category
|
|
87
110
|
}) => !category)
|
|
88
111
|
})]
|
|
89
112
|
})]
|
|
90
113
|
});
|
|
91
114
|
}
|
|
92
|
-
var _default = exports.default = (0, _compose.compose)([(0, _data.withSelect)(select => {
|
|
93
|
-
var _get;
|
|
94
|
-
const {
|
|
95
|
-
getBlockTypes,
|
|
96
|
-
getCategories,
|
|
97
|
-
hasBlockSupport,
|
|
98
|
-
isMatchingSearchTerm
|
|
99
|
-
} = select(_blocks.store);
|
|
100
|
-
const {
|
|
101
|
-
get
|
|
102
|
-
} = select(_preferences.store);
|
|
103
|
-
|
|
104
|
-
// Some hidden blocks become unregistered
|
|
105
|
-
// by removing for instance the plugin that registered them, yet
|
|
106
|
-
// they're still remain as hidden by the user's action.
|
|
107
|
-
// We consider "hidden", blocks which were hidden and
|
|
108
|
-
// are still registered.
|
|
109
|
-
const blockTypes = getBlockTypes();
|
|
110
|
-
const hiddenBlockTypes = ((_get = get('core', 'hiddenBlockTypes')) !== null && _get !== void 0 ? _get : []).filter(hiddenBlock => {
|
|
111
|
-
return blockTypes.some(registeredBlock => registeredBlock.name === hiddenBlock);
|
|
112
|
-
});
|
|
113
|
-
const numberOfHiddenBlocks = Array.isArray(hiddenBlockTypes) && hiddenBlockTypes.length;
|
|
114
|
-
return {
|
|
115
|
-
blockTypes,
|
|
116
|
-
categories: getCategories(),
|
|
117
|
-
hasBlockSupport,
|
|
118
|
-
isMatchingSearchTerm,
|
|
119
|
-
numberOfHiddenBlocks
|
|
120
|
-
};
|
|
121
|
-
}), (0, _data.withDispatch)(dispatch => {
|
|
122
|
-
const {
|
|
123
|
-
showBlockTypes
|
|
124
|
-
} = (0, _lockUnlock.unlock)(dispatch(_store.store));
|
|
125
|
-
return {
|
|
126
|
-
enableAllBlockTypes: blockTypes => {
|
|
127
|
-
const blockNames = blockTypes.map(({
|
|
128
|
-
name
|
|
129
|
-
}) => name);
|
|
130
|
-
showBlockTypes(blockNames);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
})])(BlockManager);
|
|
134
115
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blocks","require","_data","_components","_i18n","_element","_compose","_a11y","_preferences","_lockUnlock","_store","_category","_interopRequireDefault","_jsxRuntime","BlockManager","blockTypes","categories","hasBlockSupport","isMatchingSearchTerm","numberOfHiddenBlocks","enableAllBlockTypes","debouncedSpeak","useDebounce","speak","search","setSearch","useState","filter","blockType","parent","includes","useEffect","count","length","resultsFoundMessage","sprintf","_n","jsxs","className","children","jsx","Button","__next40pxDefaultSize","variant","onClick","__","SearchControl","__nextHasNoMarginBottom","label","placeholder","value","onChange","nextSearch","tabIndex","role","map","category","default","title","slug","_default","exports","compose","withSelect","select","_get","getBlockTypes","getCategories","blocksStore","get","preferencesStore","hiddenBlockTypes","hiddenBlock","some","registeredBlock","name","Array","isArray","withDispatch","dispatch","showBlockTypes","unlock","editorStore","blockNames"],"sources":["@wordpress/editor/src/components/block-manager/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { SearchControl, Button } from '@wordpress/components';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useEffect, useState } from '@wordpress/element';\nimport { useDebounce, compose } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\nimport BlockManagerCategory from './category';\n\nfunction BlockManager( {\n\tblockTypes,\n\tcategories,\n\thasBlockSupport,\n\tisMatchingSearchTerm,\n\tnumberOfHiddenBlocks,\n\tenableAllBlockTypes,\n} ) {\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst [ search, setSearch ] = useState( '' );\n\n\t// Filtering occurs here (as opposed to `withSelect`) to avoid\n\t// wasted renders by consequence of `Array#filter` producing\n\t// a new value reference on each call.\n\tblockTypes = blockTypes.filter(\n\t\t( blockType ) =>\n\t\t\thasBlockSupport( blockType, 'inserter', true ) &&\n\t\t\t( ! search || isMatchingSearchTerm( blockType, search ) ) &&\n\t\t\t( ! blockType.parent ||\n\t\t\t\tblockType.parent.includes( 'core/post-content' ) )\n\t);\n\n\t// Announce search results on change\n\tuseEffect( () => {\n\t\tif ( ! search ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = blockTypes.length;\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage );\n\t}, [ blockTypes.length, search, debouncedSpeak ] );\n\n\treturn (\n\t\t<div className=\"editor-block-manager__content\">\n\t\t\t{ !! numberOfHiddenBlocks && (\n\t\t\t\t<div className=\"editor-block-manager__disabled-blocks-count\">\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %d: number of blocks. */\n\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t'%d block is hidden.',\n\t\t\t\t\t\t\t'%d blocks are hidden.',\n\t\t\t\t\t\t\tnumberOfHiddenBlocks\n\t\t\t\t\t\t),\n\t\t\t\t\t\tnumberOfHiddenBlocks\n\t\t\t\t\t) }\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => enableAllBlockTypes( blockTypes ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<SearchControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Search for a block' ) }\n\t\t\t\tplaceholder={ __( 'Search for a block' ) }\n\t\t\t\tvalue={ search }\n\t\t\t\tonChange={ ( nextSearch ) => setSearch( nextSearch ) }\n\t\t\t\tclassName=\"editor-block-manager__search\"\n\t\t\t/>\n\t\t\t<div\n\t\t\t\ttabIndex=\"0\"\n\t\t\t\trole=\"region\"\n\t\t\t\taria-label={ __( 'Available block types' ) }\n\t\t\t\tclassName=\"editor-block-manager__results\"\n\t\t\t>\n\t\t\t\t{ blockTypes.length === 0 && (\n\t\t\t\t\t<p className=\"editor-block-manager__no-results\">\n\t\t\t\t\t\t{ __( 'No blocks found.' ) }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t\t{ categories.map( ( category ) => (\n\t\t\t\t\t<BlockManagerCategory\n\t\t\t\t\t\tkey={ category.slug }\n\t\t\t\t\t\ttitle={ category.title }\n\t\t\t\t\t\tblockTypes={ blockTypes.filter(\n\t\t\t\t\t\t\t( blockType ) =>\n\t\t\t\t\t\t\t\tblockType.category === category.slug\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t\t<BlockManagerCategory\n\t\t\t\t\ttitle={ __( 'Uncategorized' ) }\n\t\t\t\t\tblockTypes={ blockTypes.filter(\n\t\t\t\t\t\t( { category } ) => ! category\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockTypes,\n\t\t\tgetCategories,\n\t\t\thasBlockSupport,\n\t\t\tisMatchingSearchTerm,\n\t\t} = select( blocksStore );\n\t\tconst { get } = select( preferencesStore );\n\n\t\t// Some hidden blocks become unregistered\n\t\t// by removing for instance the plugin that registered them, yet\n\t\t// they're still remain as hidden by the user's action.\n\t\t// We consider \"hidden\", blocks which were hidden and\n\t\t// are still registered.\n\t\tconst blockTypes = getBlockTypes();\n\t\tconst hiddenBlockTypes = (\n\t\t\tget( 'core', 'hiddenBlockTypes' ) ?? []\n\t\t).filter( ( hiddenBlock ) => {\n\t\t\treturn blockTypes.some(\n\t\t\t\t( registeredBlock ) => registeredBlock.name === hiddenBlock\n\t\t\t);\n\t\t} );\n\t\tconst numberOfHiddenBlocks =\n\t\t\tArray.isArray( hiddenBlockTypes ) && hiddenBlockTypes.length;\n\n\t\treturn {\n\t\t\tblockTypes,\n\t\t\tcategories: getCategories(),\n\t\t\thasBlockSupport,\n\t\t\tisMatchingSearchTerm,\n\t\t\tnumberOfHiddenBlocks,\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { showBlockTypes } = unlock( dispatch( editorStore ) );\n\t\treturn {\n\t\t\tenableAllBlockTypes: ( blockTypes ) => {\n\t\t\t\tconst blockNames = blockTypes.map( ( { name } ) => name );\n\t\t\t\tshowBlockTypes( blockNames );\n\t\t\t},\n\t\t};\n\t} ),\n] )( BlockManager );\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AAKA,IAAAQ,WAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,SAAA,GAAAC,sBAAA,CAAAX,OAAA;AAA8C,IAAAY,WAAA,GAAAZ,OAAA;AAjB9C;AACA;AACA;;AAUA;AACA;AACA;;AAKA,SAASa,YAAYA,CAAE;EACtBC,UAAU;EACVC,UAAU;EACVC,eAAe;EACfC,oBAAoB;EACpBC,oBAAoB;EACpBC;AACD,CAAC,EAAG;EACH,MAAMC,cAAc,GAAG,IAAAC,oBAAW,EAAEC,WAAK,EAAE,GAAI,CAAC;EAChD,MAAM,CAAEC,MAAM,E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;AACF,CAAE,CAAC,CACF,CAAC,CAAErE,YAAa,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_blocks","require","_data","_components","_i18n","_element","_compose","_a11y","_preferences","_lockUnlock","_store","_category","_interopRequireDefault","_jsxRuntime","BlockManager","debouncedSpeak","useDebounce","speak","search","setSearch","useState","showBlockTypes","unlock","useDispatch","editorStore","blockTypes","categories","hasBlockSupport","isMatchingSearchTerm","numberOfHiddenBlocks","useSelect","select","_select$get","_blockTypes","blocksStore","getBlockTypes","hiddenBlockTypes","preferencesStore","get","filter","hiddenBlock","some","registeredBlock","name","getCategories","Array","isArray","length","enableAllBlockTypes","newBlockTypes","blockNames","map","filteredBlockTypes","blockType","parent","includes","useEffect","count","resultsFoundMessage","sprintf","_n","jsxs","className","children","jsx","Button","__next40pxDefaultSize","variant","onClick","__","SearchControl","__nextHasNoMarginBottom","label","placeholder","value","onChange","nextSearch","tabIndex","role","category","default","title","slug"],"sources":["@wordpress/editor/src/components/block-manager/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { SearchControl, Button } from '@wordpress/components';\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useEffect, useState } from '@wordpress/element';\nimport { useDebounce } from '@wordpress/compose';\nimport { speak } from '@wordpress/a11y';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\nimport BlockManagerCategory from './category';\n\nexport default function BlockManager() {\n\tconst debouncedSpeak = useDebounce( speak, 500 );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst { showBlockTypes } = unlock( useDispatch( editorStore ) );\n\n\tconst {\n\t\tblockTypes,\n\t\tcategories,\n\t\thasBlockSupport,\n\t\tisMatchingSearchTerm,\n\t\tnumberOfHiddenBlocks,\n\t} = useSelect( ( select ) => {\n\t\t// Some hidden blocks become unregistered\n\t\t// by removing for instance the plugin that registered them, yet\n\t\t// they're still remain as hidden by the user's action.\n\t\t// We consider \"hidden\", blocks which were hidden and\n\t\t// are still registered.\n\t\tconst _blockTypes = select( blocksStore ).getBlockTypes();\n\t\tconst hiddenBlockTypes = (\n\t\t\tselect( preferencesStore ).get( 'core', 'hiddenBlockTypes' ) ?? []\n\t\t).filter( ( hiddenBlock ) => {\n\t\t\treturn _blockTypes.some(\n\t\t\t\t( registeredBlock ) => registeredBlock.name === hiddenBlock\n\t\t\t);\n\t\t} );\n\n\t\treturn {\n\t\t\tblockTypes: _blockTypes,\n\t\t\tcategories: select( blocksStore ).getCategories(),\n\t\t\thasBlockSupport: select( blocksStore ).hasBlockSupport,\n\t\t\tisMatchingSearchTerm: select( blocksStore ).isMatchingSearchTerm,\n\t\t\tnumberOfHiddenBlocks:\n\t\t\t\tArray.isArray( hiddenBlockTypes ) && hiddenBlockTypes.length,\n\t\t};\n\t}, [] );\n\n\tfunction enableAllBlockTypes( newBlockTypes ) {\n\t\tconst blockNames = newBlockTypes.map( ( { name } ) => name );\n\t\tshowBlockTypes( blockNames );\n\t}\n\n\tconst filteredBlockTypes = blockTypes.filter(\n\t\t( blockType ) =>\n\t\t\thasBlockSupport( blockType, 'inserter', true ) &&\n\t\t\t( ! search || isMatchingSearchTerm( blockType, search ) ) &&\n\t\t\t( ! blockType.parent ||\n\t\t\t\tblockType.parent.includes( 'core/post-content' ) )\n\t);\n\n\t// Announce search results on change\n\tuseEffect( () => {\n\t\tif ( ! search ) {\n\t\t\treturn;\n\t\t}\n\t\tconst count = filteredBlockTypes.length;\n\t\tconst resultsFoundMessage = sprintf(\n\t\t\t/* translators: %d: number of results. */\n\t\t\t_n( '%d result found.', '%d results found.', count ),\n\t\t\tcount\n\t\t);\n\t\tdebouncedSpeak( resultsFoundMessage );\n\t}, [ filteredBlockTypes?.length, search, debouncedSpeak ] );\n\n\treturn (\n\t\t<div className=\"editor-block-manager__content\">\n\t\t\t{ !! numberOfHiddenBlocks && (\n\t\t\t\t<div className=\"editor-block-manager__disabled-blocks-count\">\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %d: number of blocks. */\n\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t'%d block is hidden.',\n\t\t\t\t\t\t\t'%d blocks are hidden.',\n\t\t\t\t\t\t\tnumberOfHiddenBlocks\n\t\t\t\t\t\t),\n\t\t\t\t\t\tnumberOfHiddenBlocks\n\t\t\t\t\t) }\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\tenableAllBlockTypes( filteredBlockTypes )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<SearchControl\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tlabel={ __( 'Search for a block' ) }\n\t\t\t\tplaceholder={ __( 'Search for a block' ) }\n\t\t\t\tvalue={ search }\n\t\t\t\tonChange={ ( nextSearch ) => setSearch( nextSearch ) }\n\t\t\t\tclassName=\"editor-block-manager__search\"\n\t\t\t/>\n\t\t\t<div\n\t\t\t\ttabIndex=\"0\"\n\t\t\t\trole=\"region\"\n\t\t\t\taria-label={ __( 'Available block types' ) }\n\t\t\t\tclassName=\"editor-block-manager__results\"\n\t\t\t>\n\t\t\t\t{ filteredBlockTypes.length === 0 && (\n\t\t\t\t\t<p className=\"editor-block-manager__no-results\">\n\t\t\t\t\t\t{ __( 'No blocks found.' ) }\n\t\t\t\t\t</p>\n\t\t\t\t) }\n\t\t\t\t{ categories.map( ( category ) => (\n\t\t\t\t\t<BlockManagerCategory\n\t\t\t\t\t\tkey={ category.slug }\n\t\t\t\t\t\ttitle={ category.title }\n\t\t\t\t\t\tblockTypes={ filteredBlockTypes.filter(\n\t\t\t\t\t\t\t( blockType ) =>\n\t\t\t\t\t\t\t\tblockType.category === category.slug\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t) ) }\n\t\t\t\t<BlockManagerCategory\n\t\t\t\t\ttitle={ __( 'Uncategorized' ) }\n\t\t\t\t\tblockTypes={ filteredBlockTypes.filter(\n\t\t\t\t\t\t( { category } ) => ! category\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AAKA,IAAAQ,WAAA,GAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,SAAA,GAAAC,sBAAA,CAAAX,OAAA;AAA8C,IAAAY,WAAA,GAAAZ,OAAA;AAjB9C;AACA;AACA;;AAUA;AACA;AACA;;AAKe,SAASa,YAAYA,CAAA,EAAG;EACtC,MAAMC,cAAc,GAAG,IAAAC,oBAAW,EAAEC,WAAK,EAAE,GAAI,CAAC;EAChD,MAAM,CAAEC,MAAM,EAAEC,SAAS,CAAE,GAAG,IAAAC,iBAAQ,EAAE,EAAG,CAAC;EAC5C,MAAM;IAAEC;EAAe,CAAC,GAAG,IAAAC,kBAAM,EAAE,IAAAC,iBAAW,EAAEC,YAAY,CAAE,CAAC;EAE/D,MAAM;IACLC,UAAU;IACVC,UAAU;IACVC,eAAe;IACfC,oBAAoB;IACpBC;EACD,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAAA,IAAAC,WAAA;IAC5B;IACA;IACA;IACA;IACA;IACA,MAAMC,WAAW,GAAGF,MAAM,CAA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,GAAG;MACZC,IAAI,EAAC,QAAQ;MACb,cAAa,IAAAT,QAAE,EAAE,uBAAwB,CAAG;MAC5CP,SAAS,EAAC,+BAA+B;MAAAC,QAAA,GAEvCX,kBAAkB,CAACL,MAAM,KAAK,CAAC,iBAChC,IAAAlC,WAAA,CAAAmD,GAAA;QAAGF,SAAS,EAAC,kCAAkC;QAAAC,QAAA,EAC5C,IAAAM,QAAE,EAAE,kBAAmB;MAAC,CACxB,CACH,EACC3C,UAAU,CAACyB,GAAG,CAAI4B,QAAQ,iBAC3B,IAAAlE,WAAA,CAAAmD,GAAA,EAACrD,SAAA,CAAAqE,OAAoB;QAEpBC,KAAK,EAAGF,QAAQ,CAACE,KAAO;QACxBxD,UAAU,EAAG2B,kBAAkB,CAACb,MAAM,CACnCc,SAAS,IACVA,SAAS,CAAC0B,QAAQ,KAAKA,QAAQ,CAACG,IAClC;MAAG,GALGH,QAAQ,CAACG,IAMf,CACA,CAAC,eACH,IAAArE,WAAA,CAAAmD,GAAA,EAACrD,SAAA,CAAAqE,OAAoB;QACpBC,KAAK,EAAG,IAAAZ,QAAE,EAAE,eAAgB,CAAG;QAC/B5C,UAAU,EAAG2B,kBAAkB,CAACb,MAAM,CACrC,CAAE;UAAEwC;QAAS,CAAC,KAAM,CAAEA,QACvB;MAAG,CACH,CAAC;IAAA,CACE,CAAC;EAAA,CACF,CAAC;AAER","ignoreList":[]}
|
|
@@ -19,7 +19,6 @@ var _compose = require("@wordpress/compose");
|
|
|
19
19
|
var _htmlEntities = require("@wordpress/html-entities");
|
|
20
20
|
var _constants = require("../../store/constants");
|
|
21
21
|
var _store = require("../../store");
|
|
22
|
-
var _lockUnlock = require("../../lock-unlock");
|
|
23
22
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
24
23
|
/**
|
|
25
24
|
* External dependencies
|
|
@@ -33,17 +32,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
33
32
|
* Internal dependencies
|
|
34
33
|
*/
|
|
35
34
|
|
|
36
|
-
const
|
|
37
|
-
// translators: 1: Pattern title.
|
|
38
|
-
wp_pattern: (0, _i18n.__)('Editing pattern: %s'),
|
|
39
|
-
// translators: 1: Navigation menu title.
|
|
40
|
-
wp_navigation: (0, _i18n.__)('Editing navigation menu: %s'),
|
|
41
|
-
// translators: 1: Template title.
|
|
42
|
-
wp_template: (0, _i18n.__)('Editing template: %s'),
|
|
43
|
-
// translators: 1: Template part title.
|
|
44
|
-
wp_template_part: (0, _i18n.__)('Editing template part: %s')
|
|
45
|
-
};
|
|
46
|
-
const MotionButton = (0, _components.__unstableMotion)(_components.Button);
|
|
35
|
+
/** @typedef {import("@wordpress/components").IconType} IconType */const MotionButton = (0, _components.__unstableMotion)(_components.Button);
|
|
47
36
|
|
|
48
37
|
/**
|
|
49
38
|
* This component renders a navigation bar at the top of the editor. It displays the title of the current document,
|
|
@@ -54,21 +43,21 @@ const MotionButton = (0, _components.__unstableMotion)(_components.Button);
|
|
|
54
43
|
* ```jsx
|
|
55
44
|
* <DocumentBar />
|
|
56
45
|
* ```
|
|
57
|
-
* @param {Object}
|
|
58
|
-
* @param {string}
|
|
59
|
-
*
|
|
60
|
-
* @param {
|
|
61
|
-
*
|
|
46
|
+
* @param {Object} props The component props.
|
|
47
|
+
* @param {string} props.title A title for the document, defaulting to the document or
|
|
48
|
+
* template title currently being edited.
|
|
49
|
+
* @param {IconType} props.icon An icon for the document, no default.
|
|
50
|
+
* (A default icon indicating the document post type is no longer used.)
|
|
62
51
|
*
|
|
63
52
|
* @return {JSX.Element} The rendered DocumentBar component.
|
|
64
53
|
*/
|
|
65
54
|
function DocumentBar(props) {
|
|
66
55
|
const {
|
|
67
56
|
postType,
|
|
57
|
+
postTypeLabel,
|
|
68
58
|
documentTitle,
|
|
69
59
|
isNotFound,
|
|
70
60
|
isUnsyncedPattern,
|
|
71
|
-
templateIcon,
|
|
72
61
|
templateTitle,
|
|
73
62
|
onNavigateToPreviousEntityRecord
|
|
74
63
|
} = (0, _data.useSelect)(select => {
|
|
@@ -80,20 +69,20 @@ function DocumentBar(props) {
|
|
|
80
69
|
} = select(_store.store);
|
|
81
70
|
const {
|
|
82
71
|
getEditedEntityRecord,
|
|
72
|
+
getPostType,
|
|
83
73
|
isResolving: isResolvingSelector
|
|
84
74
|
} = select(_coreData.store);
|
|
85
75
|
const _postType = getCurrentPostType();
|
|
86
76
|
const _postId = getCurrentPostId();
|
|
87
77
|
const _document = getEditedEntityRecord('postType', _postType, _postId);
|
|
88
78
|
const _templateInfo = getTemplateInfo(_document);
|
|
79
|
+
const _postTypeLabel = getPostType(_postType)?.labels?.singular_name;
|
|
89
80
|
return {
|
|
90
81
|
postType: _postType,
|
|
82
|
+
postTypeLabel: _postTypeLabel,
|
|
91
83
|
documentTitle: _document.title,
|
|
92
84
|
isNotFound: !_document && !isResolvingSelector('getEditedEntityRecord', 'postType', _postType, _postId),
|
|
93
85
|
isUnsyncedPattern: _document?.wp_pattern_sync_status === 'unsynced',
|
|
94
|
-
templateIcon: (0, _lockUnlock.unlock)(select(_store.store)).getPostIcon(_postType, {
|
|
95
|
-
area: _document?.area
|
|
96
|
-
}),
|
|
97
86
|
templateTitle: _templateInfo.title,
|
|
98
87
|
onNavigateToPreviousEntityRecord: getEditorSettings().onNavigateToPreviousEntityRecord
|
|
99
88
|
};
|
|
@@ -107,7 +96,7 @@ function DocumentBar(props) {
|
|
|
107
96
|
const hasBackButton = !!onNavigateToPreviousEntityRecord;
|
|
108
97
|
const entityTitle = isTemplate ? templateTitle : documentTitle;
|
|
109
98
|
const title = props.title || entityTitle;
|
|
110
|
-
const icon = props.icon
|
|
99
|
+
const icon = props.icon;
|
|
111
100
|
const mountedRef = (0, _element.useRef)(false);
|
|
112
101
|
(0, _element.useEffect)(() => {
|
|
113
102
|
mountedRef.current = true;
|
|
@@ -167,15 +156,18 @@ function DocumentBar(props) {
|
|
|
167
156
|
transition: isReducedMotion ? {
|
|
168
157
|
duration: 0
|
|
169
158
|
} : undefined,
|
|
170
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.BlockIcon, {
|
|
159
|
+
children: [icon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.BlockIcon, {
|
|
171
160
|
icon: icon
|
|
172
|
-
}), /*#__PURE__*/(0, _jsxRuntime.
|
|
161
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.__experimentalText, {
|
|
173
162
|
size: "body",
|
|
174
163
|
as: "h1",
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
164
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
165
|
+
className: "editor-document-bar__post-title",
|
|
166
|
+
children: title ? (0, _htmlEntities.decodeEntities)(title) : (0, _i18n.__)('No title')
|
|
167
|
+
}), postTypeLabel && !props.title && /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
168
|
+
className: "editor-document-bar__post-type-label",
|
|
169
|
+
children: '· ' + (0, _htmlEntities.decodeEntities)(postTypeLabel)
|
|
170
|
+
})]
|
|
179
171
|
})]
|
|
180
172
|
}, hasBackButton), /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
181
173
|
className: "editor-document-bar__shortcut",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_i18n","_data","_components","_blockEditor","_icons","_keycodes","_coreData","_commands","_element","_compose","_htmlEntities","_constants","_store","_lockUnlock","_jsxRuntime","TYPE_LABELS","wp_pattern","__","wp_navigation","wp_template","wp_template_part","MotionButton","motion","Button","DocumentBar","props","postType","documentTitle","isNotFound","isUnsyncedPattern","templateIcon","templateTitle","onNavigateToPreviousEntityRecord","useSelect","select","getCurrentPostType","getCurrentPostId","getEditorSettings","__experimentalGetTemplateInfo","getTemplateInfo","editorStore","getEditedEntityRecord","isResolving","isResolvingSelector","coreStore","_postType","_postId","_document","_templateInfo","title","wp_pattern_sync_status","unlock","getPostIcon","area","open","openCommandCenter","useDispatch","commandsStore","isReducedMotion","useReducedMotion","isTemplate","TEMPLATE_POST_TYPES","includes","isGlobalEntity","GLOBAL_POST_TYPES","hasBackButton","entityTitle","icon","mountedRef","useRef","useEffect","current","jsxs","className","clsx","children","jsx","__unstableAnimatePresence","isRTL","chevronRightSmall","chevronLeftSmall","onClick","event","stopPropagation","size","initial","opacity","transform","animate","exit","transition","duration","undefined","__experimentalText","__unstableMotion","div","BlockIcon","as","sprintf","decodeEntities","displayShortcut","primary"],"sources":["@wordpress/editor/src/components/document-bar/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, isRTL, sprintf } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '@wordpress/components';\nimport { BlockIcon } from '@wordpress/block-editor';\nimport { chevronLeftSmall, chevronRightSmall } from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as commandsStore } from '@wordpress/commands';\nimport { useRef, useEffect } from '@wordpress/element';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_POST_TYPES, GLOBAL_POST_TYPES } from '../../store/constants';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst TYPE_LABELS = {\n\t// translators: 1: Pattern title.\n\twp_pattern: __( 'Editing pattern: %s' ),\n\t// translators: 1: Navigation menu title.\n\twp_navigation: __( 'Editing navigation menu: %s' ),\n\t// translators: 1: Template title.\n\twp_template: __( 'Editing template: %s' ),\n\t// translators: 1: Template part title.\n\twp_template_part: __( 'Editing template part: %s' ),\n};\n\nconst MotionButton = motion( Button );\n\n/**\n * This component renders a navigation bar at the top of the editor. It displays the title of the current document,\n * a back button (if applicable), and a command center button. It also handles different states of the document,\n * such as \"not found\" or \"unsynced\".\n *\n * @example\n * ```jsx\n * <DocumentBar />\n * ```\n * @param {Object} props The component props.\n * @param {string} props.title A title for the document, defaulting to the document or\n * template title currently being edited.\n * @param {import(\"@wordpress/components\").IconType} props.icon An icon for the document, defaulting to an icon for document\n * or template currently being edited.\n *\n * @return {JSX.Element} The rendered DocumentBar component.\n */\nexport default function DocumentBar( props ) {\n\tconst {\n\t\tpostType,\n\t\tdocumentTitle,\n\t\tisNotFound,\n\t\tisUnsyncedPattern,\n\t\ttemplateIcon,\n\t\ttemplateTitle,\n\t\tonNavigateToPreviousEntityRecord,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetCurrentPostType,\n\t\t\tgetCurrentPostId,\n\t\t\tgetEditorSettings,\n\t\t\t__experimentalGetTemplateInfo: getTemplateInfo,\n\t\t} = select( editorStore );\n\t\tconst { getEditedEntityRecord, isResolving: isResolvingSelector } =\n\t\t\tselect( coreStore );\n\t\tconst _postType = getCurrentPostType();\n\t\tconst _postId = getCurrentPostId();\n\t\tconst _document = getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\t_postType,\n\t\t\t_postId\n\t\t);\n\t\tconst _templateInfo = getTemplateInfo( _document );\n\t\treturn {\n\t\t\tpostType: _postType,\n\t\t\tdocumentTitle: _document.title,\n\t\t\tisNotFound:\n\t\t\t\t! _document &&\n\t\t\t\t! isResolvingSelector(\n\t\t\t\t\t'getEditedEntityRecord',\n\t\t\t\t\t'postType',\n\t\t\t\t\t_postType,\n\t\t\t\t\t_postId\n\t\t\t\t),\n\t\t\tisUnsyncedPattern: _document?.wp_pattern_sync_status === 'unsynced',\n\t\t\ttemplateIcon: unlock( select( editorStore ) ).getPostIcon(\n\t\t\t\t_postType,\n\t\t\t\t{\n\t\t\t\t\tarea: _document?.area,\n\t\t\t\t}\n\t\t\t),\n\t\t\ttemplateTitle: _templateInfo.title,\n\t\t\tonNavigateToPreviousEntityRecord:\n\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord,\n\t\t};\n\t}, [] );\n\n\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\tconst isReducedMotion = useReducedMotion();\n\n\tconst isTemplate = TEMPLATE_POST_TYPES.includes( postType );\n\tconst isGlobalEntity = GLOBAL_POST_TYPES.includes( postType );\n\tconst hasBackButton = !! onNavigateToPreviousEntityRecord;\n\tconst entityTitle = isTemplate ? templateTitle : documentTitle;\n\tconst title = props.title || entityTitle;\n\tconst icon = props.icon || templateIcon;\n\n\tconst mountedRef = useRef( false );\n\tuseEffect( () => {\n\t\tmountedRef.current = true;\n\t}, [] );\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ clsx( 'editor-document-bar', {\n\t\t\t\t'has-back-button': hasBackButton,\n\t\t\t\t'is-global': isGlobalEntity && ! isUnsyncedPattern,\n\t\t\t} ) }\n\t\t>\n\t\t\t<AnimatePresence>\n\t\t\t\t{ hasBackButton && (\n\t\t\t\t\t<MotionButton\n\t\t\t\t\t\tclassName=\"editor-document-bar__back\"\n\t\t\t\t\t\ticon={ isRTL() ? chevronRightSmall : chevronLeftSmall }\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\tonNavigateToPreviousEntityRecord();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tinitial={\n\t\t\t\t\t\t\tmountedRef.current\n\t\t\t\t\t\t\t\t? { opacity: 0, transform: 'translateX(15%)' }\n\t\t\t\t\t\t\t\t: false // Don't show entry animation when DocumentBar mounts.\n\t\t\t\t\t\t}\n\t\t\t\t\t\tanimate={ { opacity: 1, transform: 'translateX(0%)' } }\n\t\t\t\t\t\texit={ { opacity: 0, transform: 'translateX(15%)' } }\n\t\t\t\t\t\ttransition={\n\t\t\t\t\t\t\tisReducedMotion ? { duration: 0 } : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Back' ) }\n\t\t\t\t\t</MotionButton>\n\t\t\t\t) }\n\t\t\t</AnimatePresence>\n\t\t\t{ isNotFound ? (\n\t\t\t\t<Text>{ __( 'Document not found' ) }</Text>\n\t\t\t) : (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"editor-document-bar__command\"\n\t\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t>\n\t\t\t\t\t<motion.div\n\t\t\t\t\t\tclassName=\"editor-document-bar__title\"\n\t\t\t\t\t\t// Force entry animation when the back button is added or removed.\n\t\t\t\t\t\tkey={ hasBackButton }\n\t\t\t\t\t\tinitial={\n\t\t\t\t\t\t\tmountedRef.current\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\topacity: 0,\n\t\t\t\t\t\t\t\t\t\ttransform: hasBackButton\n\t\t\t\t\t\t\t\t\t\t\t? 'translateX(15%)'\n\t\t\t\t\t\t\t\t\t\t\t: 'translateX(-15%)',\n\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t: false // Don't show entry animation when DocumentBar mounts.\n\t\t\t\t\t\t}\n\t\t\t\t\t\tanimate={ {\n\t\t\t\t\t\t\topacity: 1,\n\t\t\t\t\t\t\ttransform: 'translateX(0%)',\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ttransition={\n\t\t\t\t\t\t\tisReducedMotion ? { duration: 0 } : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockIcon icon={ icon } />\n\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\tsize=\"body\"\n\t\t\t\t\t\t\tas=\"h1\"\n\t\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\t\t! props.title && TYPE_LABELS[ postType ]\n\t\t\t\t\t\t\t\t\t? // eslint-disable-next-line @wordpress/valid-sprintf\n\t\t\t\t\t\t\t\t\t sprintf( TYPE_LABELS[ postType ], title )\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ title\n\t\t\t\t\t\t\t\t? decodeEntities( title )\n\t\t\t\t\t\t\t\t: __( 'No title' ) }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t</motion.div>\n\t\t\t\t\t<span className=\"editor-document-bar__shortcut\">\n\t\t\t\t\t\t{ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t</span>\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAMA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,QAAA,GAAAV,OAAA;AACA,IAAAW,aAAA,GAAAX,OAAA;AAKA,IAAAY,UAAA,GAAAZ,OAAA;AACA,IAAAa,MAAA,GAAAb,OAAA;AACA,IAAAc,WAAA,GAAAd,OAAA;AAA2C,IAAAe,WAAA,GAAAf,OAAA;AA9B3C;AACA;AACA;;AAGA;AACA;AACA;;AAkBA;AACA;AACA;;AAKA,MAAMgB,WAAW,GAAG;EACnB;EACAC,UAAU,EAAE,IAAAC,QAAE,EAAE,qBAAsB,CAAC;EACvC;EACAC,aAAa,EAAE,IAAAD,QAAE,EAAE,6BAA8B,CAAC;EAClD;EACAE,WAAW,EAAE,IAAAF,QAAE,EAAE,sBAAuB,CAAC;EACzC;EACAG,gBAAgB,EAAE,IAAAH,QAAE,EAAE,2BAA4B;AACnD,CAAC;AAED,MAAMI,YAAY,GAAG,IAAAC,4BAAM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A,gBAED,IAAA7D,WAAA,CAAA8D,GAAA,EAACzE,YAAA,CAAA6F,SAAS;UAAC7B,IAAI,EAAGA;QAAM,CAAE,CAAC,eAC3B,IAAArD,WAAA,CAAA8D,GAAA,EAAC1E,WAAA,CAAA2F,kBAAI;UACJT,IAAI,EAAC,MAAM;UACXa,EAAE,EAAC,IAAI;UACP,cACC,CAAExE,KAAK,CAACwB,KAAK,IAAIlC,WAAW,CAAEW,QAAQ,CAAE;UACrC;UACA,IAAAwE,aAAO,EAAEnF,WAAW,CAAEW,QAAQ,CAAE,EAAEuB,KAAM,CAAC,GACzC2C,SACH;UAAAjB,QAAA,EAEC1B,KAAK,GACJ,IAAAkD,4BAAc,EAAElD,KAAM,CAAC,GACvB,IAAAhC,QAAE,EAAE,UAAW;QAAC,CACd,CAAC;MAAA,GAjCDgD,aAkCK,CAAC,eACb,IAAAnD,WAAA,CAAA8D,GAAA;QAAMH,SAAS,EAAC,+BAA+B;QAAAE,QAAA,EAC5CyB,yBAAe,CAACC,OAAO,CAAE,GAAI;MAAC,CAC3B,CAAC;IAAA,CACA,CACR;EAAA,CACG,CAAC;AAER","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_i18n","_data","_components","_blockEditor","_icons","_keycodes","_coreData","_commands","_element","_compose","_htmlEntities","_constants","_store","_jsxRuntime","MotionButton","motion","Button","DocumentBar","props","postType","postTypeLabel","documentTitle","isNotFound","isUnsyncedPattern","templateTitle","onNavigateToPreviousEntityRecord","useSelect","select","getCurrentPostType","getCurrentPostId","getEditorSettings","__experimentalGetTemplateInfo","getTemplateInfo","editorStore","getEditedEntityRecord","getPostType","isResolving","isResolvingSelector","coreStore","_postType","_postId","_document","_templateInfo","_postTypeLabel","labels","singular_name","title","wp_pattern_sync_status","open","openCommandCenter","useDispatch","commandsStore","isReducedMotion","useReducedMotion","isTemplate","TEMPLATE_POST_TYPES","includes","isGlobalEntity","GLOBAL_POST_TYPES","hasBackButton","entityTitle","icon","mountedRef","useRef","useEffect","current","jsxs","className","clsx","children","jsx","__unstableAnimatePresence","isRTL","chevronRightSmall","chevronLeftSmall","onClick","event","stopPropagation","size","initial","opacity","transform","animate","exit","transition","duration","undefined","__","__experimentalText","__unstableMotion","div","BlockIcon","as","decodeEntities","displayShortcut","primary"],"sources":["@wordpress/editor/src/components/document-bar/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '@wordpress/components';\nimport { BlockIcon } from '@wordpress/block-editor';\nimport { chevronLeftSmall, chevronRightSmall } from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as commandsStore } from '@wordpress/commands';\nimport { useRef, useEffect } from '@wordpress/element';\nimport { useReducedMotion } from '@wordpress/compose';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_POST_TYPES, GLOBAL_POST_TYPES } from '../../store/constants';\nimport { store as editorStore } from '../../store';\n\n/** @typedef {import(\"@wordpress/components\").IconType} IconType */\n\nconst MotionButton = motion( Button );\n\n/**\n * This component renders a navigation bar at the top of the editor. It displays the title of the current document,\n * a back button (if applicable), and a command center button. It also handles different states of the document,\n * such as \"not found\" or \"unsynced\".\n *\n * @example\n * ```jsx\n * <DocumentBar />\n * ```\n * @param {Object} props The component props.\n * @param {string} props.title A title for the document, defaulting to the document or\n * template title currently being edited.\n * @param {IconType} props.icon An icon for the document, no default.\n * (A default icon indicating the document post type is no longer used.)\n *\n * @return {JSX.Element} The rendered DocumentBar component.\n */\nexport default function DocumentBar( props ) {\n\tconst {\n\t\tpostType,\n\t\tpostTypeLabel,\n\t\tdocumentTitle,\n\t\tisNotFound,\n\t\tisUnsyncedPattern,\n\t\ttemplateTitle,\n\t\tonNavigateToPreviousEntityRecord,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetCurrentPostType,\n\t\t\tgetCurrentPostId,\n\t\t\tgetEditorSettings,\n\t\t\t__experimentalGetTemplateInfo: getTemplateInfo,\n\t\t} = select( editorStore );\n\t\tconst {\n\t\t\tgetEditedEntityRecord,\n\t\t\tgetPostType,\n\t\t\tisResolving: isResolvingSelector,\n\t\t} = select( coreStore );\n\t\tconst _postType = getCurrentPostType();\n\t\tconst _postId = getCurrentPostId();\n\t\tconst _document = getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\t_postType,\n\t\t\t_postId\n\t\t);\n\t\tconst _templateInfo = getTemplateInfo( _document );\n\t\tconst _postTypeLabel = getPostType( _postType )?.labels?.singular_name;\n\n\t\treturn {\n\t\t\tpostType: _postType,\n\t\t\tpostTypeLabel: _postTypeLabel,\n\t\t\tdocumentTitle: _document.title,\n\t\t\tisNotFound:\n\t\t\t\t! _document &&\n\t\t\t\t! isResolvingSelector(\n\t\t\t\t\t'getEditedEntityRecord',\n\t\t\t\t\t'postType',\n\t\t\t\t\t_postType,\n\t\t\t\t\t_postId\n\t\t\t\t),\n\t\t\tisUnsyncedPattern: _document?.wp_pattern_sync_status === 'unsynced',\n\t\t\ttemplateTitle: _templateInfo.title,\n\t\t\tonNavigateToPreviousEntityRecord:\n\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord,\n\t\t};\n\t}, [] );\n\n\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\tconst isReducedMotion = useReducedMotion();\n\n\tconst isTemplate = TEMPLATE_POST_TYPES.includes( postType );\n\tconst isGlobalEntity = GLOBAL_POST_TYPES.includes( postType );\n\tconst hasBackButton = !! onNavigateToPreviousEntityRecord;\n\tconst entityTitle = isTemplate ? templateTitle : documentTitle;\n\tconst title = props.title || entityTitle;\n\tconst icon = props.icon;\n\n\tconst mountedRef = useRef( false );\n\tuseEffect( () => {\n\t\tmountedRef.current = true;\n\t}, [] );\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ clsx( 'editor-document-bar', {\n\t\t\t\t'has-back-button': hasBackButton,\n\t\t\t\t'is-global': isGlobalEntity && ! isUnsyncedPattern,\n\t\t\t} ) }\n\t\t>\n\t\t\t<AnimatePresence>\n\t\t\t\t{ hasBackButton && (\n\t\t\t\t\t<MotionButton\n\t\t\t\t\t\tclassName=\"editor-document-bar__back\"\n\t\t\t\t\t\ticon={ isRTL() ? chevronRightSmall : chevronLeftSmall }\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\tonNavigateToPreviousEntityRecord();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tinitial={\n\t\t\t\t\t\t\tmountedRef.current\n\t\t\t\t\t\t\t\t? { opacity: 0, transform: 'translateX(15%)' }\n\t\t\t\t\t\t\t\t: false // Don't show entry animation when DocumentBar mounts.\n\t\t\t\t\t\t}\n\t\t\t\t\t\tanimate={ { opacity: 1, transform: 'translateX(0%)' } }\n\t\t\t\t\t\texit={ { opacity: 0, transform: 'translateX(15%)' } }\n\t\t\t\t\t\ttransition={\n\t\t\t\t\t\t\tisReducedMotion ? { duration: 0 } : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Back' ) }\n\t\t\t\t\t</MotionButton>\n\t\t\t\t) }\n\t\t\t</AnimatePresence>\n\t\t\t{ isNotFound ? (\n\t\t\t\t<Text>{ __( 'Document not found' ) }</Text>\n\t\t\t) : (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"editor-document-bar__command\"\n\t\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t>\n\t\t\t\t\t<motion.div\n\t\t\t\t\t\tclassName=\"editor-document-bar__title\"\n\t\t\t\t\t\t// Force entry animation when the back button is added or removed.\n\t\t\t\t\t\tkey={ hasBackButton }\n\t\t\t\t\t\tinitial={\n\t\t\t\t\t\t\tmountedRef.current\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\topacity: 0,\n\t\t\t\t\t\t\t\t\t\ttransform: hasBackButton\n\t\t\t\t\t\t\t\t\t\t\t? 'translateX(15%)'\n\t\t\t\t\t\t\t\t\t\t\t: 'translateX(-15%)',\n\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t: false // Don't show entry animation when DocumentBar mounts.\n\t\t\t\t\t\t}\n\t\t\t\t\t\tanimate={ {\n\t\t\t\t\t\t\topacity: 1,\n\t\t\t\t\t\t\ttransform: 'translateX(0%)',\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ttransition={\n\t\t\t\t\t\t\tisReducedMotion ? { duration: 0 } : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ icon && <BlockIcon icon={ icon } /> }\n\t\t\t\t\t\t<Text size=\"body\" as=\"h1\">\n\t\t\t\t\t\t\t<span className=\"editor-document-bar__post-title\">\n\t\t\t\t\t\t\t\t{ title\n\t\t\t\t\t\t\t\t\t? decodeEntities( title )\n\t\t\t\t\t\t\t\t\t: __( 'No title' ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t{ postTypeLabel && ! props.title && (\n\t\t\t\t\t\t\t\t<span className=\"editor-document-bar__post-type-label\">\n\t\t\t\t\t\t\t\t\t{ '· ' + decodeEntities( postTypeLabel ) }\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t</motion.div>\n\t\t\t\t\t<span className=\"editor-document-bar__shortcut\">\n\t\t\t\t\t\t{ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t</span>\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GA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+B;QAAAE,QAAA,EAC5CyB,yBAAe,CAACC,OAAO,CAAE,GAAI;MAAC,CAC3B,CAAC;IAAA,CACA,CACR;EAAA,CACG,CAAC;AAER","ignoreList":[]}
|
|
@@ -61,7 +61,6 @@ function EditorInterface({
|
|
|
61
61
|
customSavePanel,
|
|
62
62
|
forceDisableBlockTools,
|
|
63
63
|
title,
|
|
64
|
-
icon,
|
|
65
64
|
iframeProps
|
|
66
65
|
}) {
|
|
67
66
|
const {
|
|
@@ -130,7 +129,7 @@ function EditorInterface({
|
|
|
130
129
|
customSaveButton: customSaveButton,
|
|
131
130
|
forceDisableBlockTools: forceDisableBlockTools,
|
|
132
131
|
title: title,
|
|
133
|
-
|
|
132
|
+
isEditorIframed: !disableIframe
|
|
134
133
|
}),
|
|
135
134
|
editorNotices: /*#__PURE__*/(0, _jsxRuntime.jsx)(_editorNotices.default, {}),
|
|
136
135
|
secondarySidebar: !isPreviewMode && mode === 'visual' && (isInserterOpened && /*#__PURE__*/(0, _jsxRuntime.jsx)(_inserterSidebar.default, {}) || isListViewOpened && /*#__PURE__*/(0, _jsxRuntime.jsx)(_listViewSidebar.default, {})),
|