@wordpress/editor 14.33.2 → 14.33.3-next.36001005c.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/build/components/collab-sidebar/comments.js +7 -5
- package/build/components/collab-sidebar/comments.js.map +2 -2
- package/build/components/collab-sidebar/hooks.js +11 -4
- package/build/components/collab-sidebar/hooks.js.map +2 -2
- package/build/components/collab-sidebar/index.js +11 -4
- package/build/components/collab-sidebar/index.js.map +2 -2
- package/build/components/provider/index.js +0 -2
- package/build/components/provider/index.js.map +3 -3
- package/build-module/components/collab-sidebar/comments.js +7 -5
- package/build-module/components/collab-sidebar/comments.js.map +2 -2
- package/build-module/components/collab-sidebar/hooks.js +11 -4
- package/build-module/components/collab-sidebar/hooks.js.map +2 -2
- package/build-module/components/collab-sidebar/index.js +11 -4
- package/build-module/components/collab-sidebar/index.js.map +2 -2
- package/build-module/components/provider/index.js +0 -2
- package/build-module/components/provider/index.js.map +2 -2
- package/build-style/style-rtl.css +7 -11
- package/build-style/style.css +7 -11
- package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
- package/build-types/components/provider/index.d.ts.map +1 -1
- package/package.json +38 -38
- package/src/components/collab-sidebar/comments.js +20 -16
- package/src/components/collab-sidebar/hooks.js +16 -9
- package/src/components/collab-sidebar/index.js +37 -29
- package/src/components/collab-sidebar/style.scss +1 -1
- package/src/components/editor-help/style.scss +1 -1
- package/src/components/post-last-revision/style.scss +1 -1
- package/src/components/post-panel-row/style.scss +1 -0
- package/src/components/post-publish-panel/style.scss +1 -1
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +2 -2
- package/src/components/provider/index.js +0 -2
- package/src/style.scss +0 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-settings-menu/content-only-settings-menu.js +0 -186
- package/build/components/block-settings-menu/content-only-settings-menu.js.map +0 -7
- package/build-module/components/block-settings-menu/content-only-settings-menu.js +0 -161
- package/build-module/components/block-settings-menu/content-only-settings-menu.js.map +0 -7
- package/build-types/components/block-settings-menu/content-only-settings-menu.d.ts +0 -2
- package/build-types/components/block-settings-menu/content-only-settings-menu.d.ts.map +0 -1
- package/src/components/block-settings-menu/content-only-settings-menu.js +0 -185
- package/src/components/block-settings-menu/content-only-settings-menu.native.js +0 -4
- package/src/components/block-settings-menu/style.scss +0 -6
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var content_only_settings_menu_exports = {};
|
|
30
|
-
__export(content_only_settings_menu_exports, {
|
|
31
|
-
default: () => ContentOnlySettingsMenu
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(content_only_settings_menu_exports);
|
|
34
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
-
var import_block_editor = require("@wordpress/block-editor");
|
|
36
|
-
var import_core_data = require("@wordpress/core-data");
|
|
37
|
-
var import_components = require("@wordpress/components");
|
|
38
|
-
var import_data = require("@wordpress/data");
|
|
39
|
-
var import_i18n = require("@wordpress/i18n");
|
|
40
|
-
var import_store = require("../../store");
|
|
41
|
-
var import_lock_unlock = require("../../lock-unlock");
|
|
42
|
-
var import_use_post_content_blocks = __toESM(require("../provider/use-post-content-blocks"));
|
|
43
|
-
function ContentOnlySettingsMenuItems({ clientId, onClose }) {
|
|
44
|
-
const postContentBlocks = (0, import_use_post_content_blocks.default)();
|
|
45
|
-
const { entity, onNavigateToEntityRecord, canEditTemplates } = (0, import_data.useSelect)(
|
|
46
|
-
(select) => {
|
|
47
|
-
const {
|
|
48
|
-
getBlockParentsByBlockName,
|
|
49
|
-
getSettings,
|
|
50
|
-
getBlockAttributes,
|
|
51
|
-
getBlockParents
|
|
52
|
-
} = select(import_block_editor.store);
|
|
53
|
-
const { getCurrentTemplateId, getRenderingMode } = select(import_store.store);
|
|
54
|
-
const patternParent = getBlockParentsByBlockName(
|
|
55
|
-
clientId,
|
|
56
|
-
"core/block",
|
|
57
|
-
true
|
|
58
|
-
)[0];
|
|
59
|
-
let record;
|
|
60
|
-
if (patternParent) {
|
|
61
|
-
record = select(import_core_data.store).getEntityRecord(
|
|
62
|
-
"postType",
|
|
63
|
-
"wp_block",
|
|
64
|
-
getBlockAttributes(patternParent).ref
|
|
65
|
-
);
|
|
66
|
-
} else if (getRenderingMode() === "template-locked" && !getBlockParents(clientId).some(
|
|
67
|
-
(parent) => postContentBlocks.includes(parent)
|
|
68
|
-
)) {
|
|
69
|
-
record = select(import_core_data.store).getEntityRecord(
|
|
70
|
-
"postType",
|
|
71
|
-
"wp_template",
|
|
72
|
-
getCurrentTemplateId()
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
if (!record) {
|
|
76
|
-
return {};
|
|
77
|
-
}
|
|
78
|
-
const _canEditTemplates = select(import_core_data.store).canUser("create", {
|
|
79
|
-
kind: "postType",
|
|
80
|
-
name: "wp_template"
|
|
81
|
-
});
|
|
82
|
-
return {
|
|
83
|
-
canEditTemplates: _canEditTemplates,
|
|
84
|
-
entity: record,
|
|
85
|
-
onNavigateToEntityRecord: getSettings().onNavigateToEntityRecord
|
|
86
|
-
};
|
|
87
|
-
},
|
|
88
|
-
[clientId, postContentBlocks]
|
|
89
|
-
);
|
|
90
|
-
if (!entity) {
|
|
91
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
92
|
-
TemplateLockContentOnlyMenuItems,
|
|
93
|
-
{
|
|
94
|
-
clientId,
|
|
95
|
-
onClose
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
const isPattern = entity.type === "wp_block";
|
|
100
|
-
let helpText = isPattern ? (0, import_i18n.__)(
|
|
101
|
-
"Edit the pattern to move, delete, or make further changes to this block."
|
|
102
|
-
) : (0, import_i18n.__)(
|
|
103
|
-
"Edit the template to move, delete, or make further changes to this block."
|
|
104
|
-
);
|
|
105
|
-
if (!canEditTemplates) {
|
|
106
|
-
helpText = (0, import_i18n.__)(
|
|
107
|
-
"Only users with permissions to edit the template can move or delete this block"
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
111
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.__unstableBlockSettingsMenuFirstItem, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
112
|
-
import_components.MenuItem,
|
|
113
|
-
{
|
|
114
|
-
onClick: () => {
|
|
115
|
-
onNavigateToEntityRecord({
|
|
116
|
-
postId: entity.id,
|
|
117
|
-
postType: entity.type
|
|
118
|
-
});
|
|
119
|
-
},
|
|
120
|
-
disabled: !canEditTemplates,
|
|
121
|
-
children: isPattern ? (0, import_i18n.__)("Edit pattern") : (0, import_i18n.__)("Edit template")
|
|
122
|
-
}
|
|
123
|
-
) }),
|
|
124
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
125
|
-
import_components.__experimentalText,
|
|
126
|
-
{
|
|
127
|
-
variant: "muted",
|
|
128
|
-
as: "p",
|
|
129
|
-
className: "editor-content-only-settings-menu__description",
|
|
130
|
-
children: helpText
|
|
131
|
-
}
|
|
132
|
-
)
|
|
133
|
-
] });
|
|
134
|
-
}
|
|
135
|
-
function TemplateLockContentOnlyMenuItems({ clientId, onClose }) {
|
|
136
|
-
const { contentLockingParent } = (0, import_data.useSelect)(
|
|
137
|
-
(select) => {
|
|
138
|
-
const { getContentLockingParent } = (0, import_lock_unlock.unlock)(
|
|
139
|
-
select(import_block_editor.store)
|
|
140
|
-
);
|
|
141
|
-
return {
|
|
142
|
-
contentLockingParent: getContentLockingParent(clientId)
|
|
143
|
-
};
|
|
144
|
-
},
|
|
145
|
-
[clientId]
|
|
146
|
-
);
|
|
147
|
-
const blockDisplayInformation = (0, import_block_editor.useBlockDisplayInformation)(contentLockingParent);
|
|
148
|
-
const blockEditorActions = (0, import_data.useDispatch)(import_block_editor.store);
|
|
149
|
-
if (!blockDisplayInformation?.title) {
|
|
150
|
-
return null;
|
|
151
|
-
}
|
|
152
|
-
const { modifyContentLockBlock } = (0, import_lock_unlock.unlock)(blockEditorActions);
|
|
153
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
154
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.__unstableBlockSettingsMenuFirstItem, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
155
|
-
import_components.MenuItem,
|
|
156
|
-
{
|
|
157
|
-
onClick: () => {
|
|
158
|
-
modifyContentLockBlock(contentLockingParent);
|
|
159
|
-
onClose();
|
|
160
|
-
},
|
|
161
|
-
children: (0, import_i18n._x)("Unlock", "Unlock content locked blocks")
|
|
162
|
-
}
|
|
163
|
-
) }),
|
|
164
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
165
|
-
import_components.__experimentalText,
|
|
166
|
-
{
|
|
167
|
-
variant: "muted",
|
|
168
|
-
as: "p",
|
|
169
|
-
className: "editor-content-only-settings-menu__description",
|
|
170
|
-
children: (0, import_i18n.__)(
|
|
171
|
-
"Temporarily unlock the parent block to edit, delete or make further changes to this block."
|
|
172
|
-
)
|
|
173
|
-
}
|
|
174
|
-
)
|
|
175
|
-
] });
|
|
176
|
-
}
|
|
177
|
-
function ContentOnlySettingsMenu() {
|
|
178
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.BlockSettingsMenuControls, { children: ({ selectedClientIds, onClose }) => selectedClientIds.length === 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
179
|
-
ContentOnlySettingsMenuItems,
|
|
180
|
-
{
|
|
181
|
-
clientId: selectedClientIds[0],
|
|
182
|
-
onClose
|
|
183
|
-
}
|
|
184
|
-
) });
|
|
185
|
-
}
|
|
186
|
-
//# sourceMappingURL=content-only-settings-menu.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/block-settings-menu/content-only-settings-menu.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tBlockSettingsMenuControls,\n\t__unstableBlockSettingsMenuFirstItem as BlockSettingsMenuFirstItem,\n\tstore as blockEditorStore,\n\tuseBlockDisplayInformation,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalText as Text, MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport usePostContentBlocks from '../provider/use-post-content-blocks';\n\nfunction ContentOnlySettingsMenuItems( { clientId, onClose } ) {\n\tconst postContentBlocks = usePostContentBlocks();\n\tconst { entity, onNavigateToEntityRecord, canEditTemplates } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetSettings,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlockParents,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getCurrentTemplateId, getRenderingMode } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst patternParent = getBlockParentsByBlockName(\n\t\t\t\tclientId,\n\t\t\t\t'core/block',\n\t\t\t\ttrue\n\t\t\t)[ 0 ];\n\n\t\t\tlet record;\n\t\t\tif ( patternParent ) {\n\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_block',\n\t\t\t\t\tgetBlockAttributes( patternParent ).ref\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\tgetRenderingMode() === 'template-locked' &&\n\t\t\t\t! getBlockParents( clientId ).some( ( parent ) =>\n\t\t\t\t\tpostContentBlocks.includes( parent )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template',\n\t\t\t\t\tgetCurrentTemplateId()\n\t\t\t\t);\n\t\t\t}\n\t\t\tif ( ! record ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst _canEditTemplates = select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} );\n\t\t\treturn {\n\t\t\t\tcanEditTemplates: _canEditTemplates,\n\t\t\t\tentity: record,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\tgetSettings().onNavigateToEntityRecord,\n\t\t\t};\n\t\t},\n\t\t[ clientId, postContentBlocks ]\n\t);\n\n\tif ( ! entity ) {\n\t\treturn (\n\t\t\t<TemplateLockContentOnlyMenuItems\n\t\t\t\tclientId={ clientId }\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst isPattern = entity.type === 'wp_block';\n\tlet helpText = isPattern\n\t\t? __(\n\t\t\t\t'Edit the pattern to move, delete, or make further changes to this block.'\n\t\t )\n\t\t: __(\n\t\t\t\t'Edit the template to move, delete, or make further changes to this block.'\n\t\t );\n\n\tif ( ! canEditTemplates ) {\n\t\thelpText = __(\n\t\t\t'Only users with permissions to edit the template can move or delete this block'\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\tpostId: entity.id,\n\t\t\t\t\t\t\tpostType: entity.type,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdisabled={ ! canEditTemplates }\n\t\t\t\t>\n\t\t\t\t\t{ isPattern ? __( 'Edit pattern' ) : __( 'Edit template' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ helpText }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nfunction TemplateLockContentOnlyMenuItems( { clientId, onClose } ) {\n\tconst { contentLockingParent } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getContentLockingParent } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcontentLockingParent: getContentLockingParent( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst blockDisplayInformation =\n\t\tuseBlockDisplayInformation( contentLockingParent );\n\tconst blockEditorActions = useDispatch( blockEditorStore );\n\tif ( ! blockDisplayInformation?.title ) {\n\t\treturn null;\n\t}\n\n\tconst { modifyContentLockBlock } = unlock( blockEditorActions );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tmodifyContentLockBlock( contentLockingParent );\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ _x( 'Unlock', 'Unlock content locked blocks' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ __(\n\t\t\t\t\t'Temporarily unlock the parent block to edit, delete or make further changes to this block.'\n\t\t\t\t) }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nexport default function ContentOnlySettingsMenu() {\n\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { selectedClientIds, onClose } ) =>\n\t\t\t\tselectedClientIds.length === 1 && (\n\t\t\t\t\t<ContentOnlySettingsMenuItems\n\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t</BlockSettingsMenuControls>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA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wB,oBAAqB;AAC7C,kBAAQ;AAAA,QACT;AAAA,QAEE,8BAAI,UAAU,8BAA+B;AAAA;AAAA,IAChD,GACD;AAAA,IACA;AAAA,MAAC,kBAAAC;AAAA,MAAA;AAAA,QACA,SAAQ;AAAA,QACR,IAAG;AAAA,QACH,WAAU;AAAA,QAER;AAAA,UACD;AAAA,QACD;AAAA;AAAA,IACD;AAAA,KACD;AAEF;AAEe,SAAR,0BAA2C;AACjD,SACC,4CAAC,iDACE,WAAE,EAAE,mBAAmB,QAAQ,MAChC,kBAAkB,WAAW,KAC5B;AAAA,IAAC;AAAA;AAAA,MACA,UAAW,kBAAmB,CAAE;AAAA,MAChC;AAAA;AAAA,EACD,GAGH;AAEF;",
|
|
6
|
-
"names": ["usePostContentBlocks", "blockEditorStore", "editorStore", "coreStore", "BlockSettingsMenuFirstItem", "Text"]
|
|
7
|
-
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
BlockSettingsMenuControls,
|
|
4
|
-
__unstableBlockSettingsMenuFirstItem as BlockSettingsMenuFirstItem,
|
|
5
|
-
store as blockEditorStore,
|
|
6
|
-
useBlockDisplayInformation
|
|
7
|
-
} from "@wordpress/block-editor";
|
|
8
|
-
import { store as coreStore } from "@wordpress/core-data";
|
|
9
|
-
import { __experimentalText as Text, MenuItem } from "@wordpress/components";
|
|
10
|
-
import { useSelect, useDispatch } from "@wordpress/data";
|
|
11
|
-
import { __, _x } from "@wordpress/i18n";
|
|
12
|
-
import { store as editorStore } from "../../store";
|
|
13
|
-
import { unlock } from "../../lock-unlock";
|
|
14
|
-
import usePostContentBlocks from "../provider/use-post-content-blocks";
|
|
15
|
-
function ContentOnlySettingsMenuItems({ clientId, onClose }) {
|
|
16
|
-
const postContentBlocks = usePostContentBlocks();
|
|
17
|
-
const { entity, onNavigateToEntityRecord, canEditTemplates } = useSelect(
|
|
18
|
-
(select) => {
|
|
19
|
-
const {
|
|
20
|
-
getBlockParentsByBlockName,
|
|
21
|
-
getSettings,
|
|
22
|
-
getBlockAttributes,
|
|
23
|
-
getBlockParents
|
|
24
|
-
} = select(blockEditorStore);
|
|
25
|
-
const { getCurrentTemplateId, getRenderingMode } = select(editorStore);
|
|
26
|
-
const patternParent = getBlockParentsByBlockName(
|
|
27
|
-
clientId,
|
|
28
|
-
"core/block",
|
|
29
|
-
true
|
|
30
|
-
)[0];
|
|
31
|
-
let record;
|
|
32
|
-
if (patternParent) {
|
|
33
|
-
record = select(coreStore).getEntityRecord(
|
|
34
|
-
"postType",
|
|
35
|
-
"wp_block",
|
|
36
|
-
getBlockAttributes(patternParent).ref
|
|
37
|
-
);
|
|
38
|
-
} else if (getRenderingMode() === "template-locked" && !getBlockParents(clientId).some(
|
|
39
|
-
(parent) => postContentBlocks.includes(parent)
|
|
40
|
-
)) {
|
|
41
|
-
record = select(coreStore).getEntityRecord(
|
|
42
|
-
"postType",
|
|
43
|
-
"wp_template",
|
|
44
|
-
getCurrentTemplateId()
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
if (!record) {
|
|
48
|
-
return {};
|
|
49
|
-
}
|
|
50
|
-
const _canEditTemplates = select(coreStore).canUser("create", {
|
|
51
|
-
kind: "postType",
|
|
52
|
-
name: "wp_template"
|
|
53
|
-
});
|
|
54
|
-
return {
|
|
55
|
-
canEditTemplates: _canEditTemplates,
|
|
56
|
-
entity: record,
|
|
57
|
-
onNavigateToEntityRecord: getSettings().onNavigateToEntityRecord
|
|
58
|
-
};
|
|
59
|
-
},
|
|
60
|
-
[clientId, postContentBlocks]
|
|
61
|
-
);
|
|
62
|
-
if (!entity) {
|
|
63
|
-
return /* @__PURE__ */ jsx(
|
|
64
|
-
TemplateLockContentOnlyMenuItems,
|
|
65
|
-
{
|
|
66
|
-
clientId,
|
|
67
|
-
onClose
|
|
68
|
-
}
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
const isPattern = entity.type === "wp_block";
|
|
72
|
-
let helpText = isPattern ? __(
|
|
73
|
-
"Edit the pattern to move, delete, or make further changes to this block."
|
|
74
|
-
) : __(
|
|
75
|
-
"Edit the template to move, delete, or make further changes to this block."
|
|
76
|
-
);
|
|
77
|
-
if (!canEditTemplates) {
|
|
78
|
-
helpText = __(
|
|
79
|
-
"Only users with permissions to edit the template can move or delete this block"
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
83
|
-
/* @__PURE__ */ jsx(BlockSettingsMenuFirstItem, { children: /* @__PURE__ */ jsx(
|
|
84
|
-
MenuItem,
|
|
85
|
-
{
|
|
86
|
-
onClick: () => {
|
|
87
|
-
onNavigateToEntityRecord({
|
|
88
|
-
postId: entity.id,
|
|
89
|
-
postType: entity.type
|
|
90
|
-
});
|
|
91
|
-
},
|
|
92
|
-
disabled: !canEditTemplates,
|
|
93
|
-
children: isPattern ? __("Edit pattern") : __("Edit template")
|
|
94
|
-
}
|
|
95
|
-
) }),
|
|
96
|
-
/* @__PURE__ */ jsx(
|
|
97
|
-
Text,
|
|
98
|
-
{
|
|
99
|
-
variant: "muted",
|
|
100
|
-
as: "p",
|
|
101
|
-
className: "editor-content-only-settings-menu__description",
|
|
102
|
-
children: helpText
|
|
103
|
-
}
|
|
104
|
-
)
|
|
105
|
-
] });
|
|
106
|
-
}
|
|
107
|
-
function TemplateLockContentOnlyMenuItems({ clientId, onClose }) {
|
|
108
|
-
const { contentLockingParent } = useSelect(
|
|
109
|
-
(select) => {
|
|
110
|
-
const { getContentLockingParent } = unlock(
|
|
111
|
-
select(blockEditorStore)
|
|
112
|
-
);
|
|
113
|
-
return {
|
|
114
|
-
contentLockingParent: getContentLockingParent(clientId)
|
|
115
|
-
};
|
|
116
|
-
},
|
|
117
|
-
[clientId]
|
|
118
|
-
);
|
|
119
|
-
const blockDisplayInformation = useBlockDisplayInformation(contentLockingParent);
|
|
120
|
-
const blockEditorActions = useDispatch(blockEditorStore);
|
|
121
|
-
if (!blockDisplayInformation?.title) {
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
const { modifyContentLockBlock } = unlock(blockEditorActions);
|
|
125
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
126
|
-
/* @__PURE__ */ jsx(BlockSettingsMenuFirstItem, { children: /* @__PURE__ */ jsx(
|
|
127
|
-
MenuItem,
|
|
128
|
-
{
|
|
129
|
-
onClick: () => {
|
|
130
|
-
modifyContentLockBlock(contentLockingParent);
|
|
131
|
-
onClose();
|
|
132
|
-
},
|
|
133
|
-
children: _x("Unlock", "Unlock content locked blocks")
|
|
134
|
-
}
|
|
135
|
-
) }),
|
|
136
|
-
/* @__PURE__ */ jsx(
|
|
137
|
-
Text,
|
|
138
|
-
{
|
|
139
|
-
variant: "muted",
|
|
140
|
-
as: "p",
|
|
141
|
-
className: "editor-content-only-settings-menu__description",
|
|
142
|
-
children: __(
|
|
143
|
-
"Temporarily unlock the parent block to edit, delete or make further changes to this block."
|
|
144
|
-
)
|
|
145
|
-
}
|
|
146
|
-
)
|
|
147
|
-
] });
|
|
148
|
-
}
|
|
149
|
-
function ContentOnlySettingsMenu() {
|
|
150
|
-
return /* @__PURE__ */ jsx(BlockSettingsMenuControls, { children: ({ selectedClientIds, onClose }) => selectedClientIds.length === 1 && /* @__PURE__ */ jsx(
|
|
151
|
-
ContentOnlySettingsMenuItems,
|
|
152
|
-
{
|
|
153
|
-
clientId: selectedClientIds[0],
|
|
154
|
-
onClose
|
|
155
|
-
}
|
|
156
|
-
) });
|
|
157
|
-
}
|
|
158
|
-
export {
|
|
159
|
-
ContentOnlySettingsMenu as default
|
|
160
|
-
};
|
|
161
|
-
//# sourceMappingURL=content-only-settings-menu.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/block-settings-menu/content-only-settings-menu.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tBlockSettingsMenuControls,\n\t__unstableBlockSettingsMenuFirstItem as BlockSettingsMenuFirstItem,\n\tstore as blockEditorStore,\n\tuseBlockDisplayInformation,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __experimentalText as Text, MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport usePostContentBlocks from '../provider/use-post-content-blocks';\n\nfunction ContentOnlySettingsMenuItems( { clientId, onClose } ) {\n\tconst postContentBlocks = usePostContentBlocks();\n\tconst { entity, onNavigateToEntityRecord, canEditTemplates } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetSettings,\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlockParents,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getCurrentTemplateId, getRenderingMode } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst patternParent = getBlockParentsByBlockName(\n\t\t\t\tclientId,\n\t\t\t\t'core/block',\n\t\t\t\ttrue\n\t\t\t)[ 0 ];\n\n\t\t\tlet record;\n\t\t\tif ( patternParent ) {\n\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_block',\n\t\t\t\t\tgetBlockAttributes( patternParent ).ref\n\t\t\t\t);\n\t\t\t} else if (\n\t\t\t\tgetRenderingMode() === 'template-locked' &&\n\t\t\t\t! getBlockParents( clientId ).some( ( parent ) =>\n\t\t\t\t\tpostContentBlocks.includes( parent )\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\trecord = select( coreStore ).getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'wp_template',\n\t\t\t\t\tgetCurrentTemplateId()\n\t\t\t\t);\n\t\t\t}\n\t\t\tif ( ! record ) {\n\t\t\t\treturn {};\n\t\t\t}\n\t\t\tconst _canEditTemplates = select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} );\n\t\t\treturn {\n\t\t\t\tcanEditTemplates: _canEditTemplates,\n\t\t\t\tentity: record,\n\t\t\t\tonNavigateToEntityRecord:\n\t\t\t\t\tgetSettings().onNavigateToEntityRecord,\n\t\t\t};\n\t\t},\n\t\t[ clientId, postContentBlocks ]\n\t);\n\n\tif ( ! entity ) {\n\t\treturn (\n\t\t\t<TemplateLockContentOnlyMenuItems\n\t\t\t\tclientId={ clientId }\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t);\n\t}\n\n\tconst isPattern = entity.type === 'wp_block';\n\tlet helpText = isPattern\n\t\t? __(\n\t\t\t\t'Edit the pattern to move, delete, or make further changes to this block.'\n\t\t )\n\t\t: __(\n\t\t\t\t'Edit the template to move, delete, or make further changes to this block.'\n\t\t );\n\n\tif ( ! canEditTemplates ) {\n\t\thelpText = __(\n\t\t\t'Only users with permissions to edit the template can move or delete this block'\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\t\t\tpostId: entity.id,\n\t\t\t\t\t\t\tpostType: entity.type,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tdisabled={ ! canEditTemplates }\n\t\t\t\t>\n\t\t\t\t\t{ isPattern ? __( 'Edit pattern' ) : __( 'Edit template' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ helpText }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nfunction TemplateLockContentOnlyMenuItems( { clientId, onClose } ) {\n\tconst { contentLockingParent } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getContentLockingParent } = unlock(\n\t\t\t\tselect( blockEditorStore )\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcontentLockingParent: getContentLockingParent( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst blockDisplayInformation =\n\t\tuseBlockDisplayInformation( contentLockingParent );\n\tconst blockEditorActions = useDispatch( blockEditorStore );\n\tif ( ! blockDisplayInformation?.title ) {\n\t\treturn null;\n\t}\n\n\tconst { modifyContentLockBlock } = unlock( blockEditorActions );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockSettingsMenuFirstItem>\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tmodifyContentLockBlock( contentLockingParent );\n\t\t\t\t\t\tonClose();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ _x( 'Unlock', 'Unlock content locked blocks' ) }\n\t\t\t\t</MenuItem>\n\t\t\t</BlockSettingsMenuFirstItem>\n\t\t\t<Text\n\t\t\t\tvariant=\"muted\"\n\t\t\t\tas=\"p\"\n\t\t\t\tclassName=\"editor-content-only-settings-menu__description\"\n\t\t\t>\n\t\t\t\t{ __(\n\t\t\t\t\t'Temporarily unlock the parent block to edit, delete or make further changes to this block.'\n\t\t\t\t) }\n\t\t\t</Text>\n\t\t</>\n\t);\n}\n\nexport default function ContentOnlySettingsMenu() {\n\treturn (\n\t\t<BlockSettingsMenuControls>\n\t\t\t{ ( { selectedClientIds, onClose } ) =>\n\t\t\t\tselectedClientIds.length === 1 && (\n\t\t\t\t\t<ContentOnlySettingsMenuItems\n\t\t\t\t\t\tclientId={ selectedClientIds[ 0 ] }\n\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t/>\n\t\t\t\t)\n\t\t\t}\n\t\t</BlockSetting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kBAAmB;AAE9D,SACC,iCACC;AAAA,wBAAC,8BACA;AAAA,MAAC;AAAA;AAAA,QACA,SAAU,MAAM;AACf,iCAAwB,oBAAqB;AAC7C,kBAAQ;AAAA,QACT;AAAA,QAEE,aAAI,UAAU,8BAA+B;AAAA;AAAA,IAChD,GACD;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,SAAQ;AAAA,QACR,IAAG;AAAA,QACH,WAAU;AAAA,QAER;AAAA,UACD;AAAA,QACD;AAAA;AAAA,IACD;AAAA,KACD;AAEF;AAEe,SAAR,0BAA2C;AACjD,SACC,oBAAC,6BACE,WAAE,EAAE,mBAAmB,QAAQ,MAChC,kBAAkB,WAAW,KAC5B;AAAA,IAAC;AAAA;AAAA,MACA,UAAW,kBAAmB,CAAE;AAAA,MAChC;AAAA;AAAA,EACD,GAGH;AAEF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"content-only-settings-menu.d.ts","sourceRoot":"","sources":["../../../src/components/block-settings-menu/content-only-settings-menu.js"],"names":[],"mappings":"AA2KA,+EAaC"}
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import {
|
|
5
|
-
BlockSettingsMenuControls,
|
|
6
|
-
__unstableBlockSettingsMenuFirstItem as BlockSettingsMenuFirstItem,
|
|
7
|
-
store as blockEditorStore,
|
|
8
|
-
useBlockDisplayInformation,
|
|
9
|
-
} from '@wordpress/block-editor';
|
|
10
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
11
|
-
import { __experimentalText as Text, MenuItem } from '@wordpress/components';
|
|
12
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
13
|
-
import { __, _x } from '@wordpress/i18n';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Internal dependencies
|
|
17
|
-
*/
|
|
18
|
-
import { store as editorStore } from '../../store';
|
|
19
|
-
import { unlock } from '../../lock-unlock';
|
|
20
|
-
import usePostContentBlocks from '../provider/use-post-content-blocks';
|
|
21
|
-
|
|
22
|
-
function ContentOnlySettingsMenuItems( { clientId, onClose } ) {
|
|
23
|
-
const postContentBlocks = usePostContentBlocks();
|
|
24
|
-
const { entity, onNavigateToEntityRecord, canEditTemplates } = useSelect(
|
|
25
|
-
( select ) => {
|
|
26
|
-
const {
|
|
27
|
-
getBlockParentsByBlockName,
|
|
28
|
-
getSettings,
|
|
29
|
-
getBlockAttributes,
|
|
30
|
-
getBlockParents,
|
|
31
|
-
} = select( blockEditorStore );
|
|
32
|
-
const { getCurrentTemplateId, getRenderingMode } =
|
|
33
|
-
select( editorStore );
|
|
34
|
-
const patternParent = getBlockParentsByBlockName(
|
|
35
|
-
clientId,
|
|
36
|
-
'core/block',
|
|
37
|
-
true
|
|
38
|
-
)[ 0 ];
|
|
39
|
-
|
|
40
|
-
let record;
|
|
41
|
-
if ( patternParent ) {
|
|
42
|
-
record = select( coreStore ).getEntityRecord(
|
|
43
|
-
'postType',
|
|
44
|
-
'wp_block',
|
|
45
|
-
getBlockAttributes( patternParent ).ref
|
|
46
|
-
);
|
|
47
|
-
} else if (
|
|
48
|
-
getRenderingMode() === 'template-locked' &&
|
|
49
|
-
! getBlockParents( clientId ).some( ( parent ) =>
|
|
50
|
-
postContentBlocks.includes( parent )
|
|
51
|
-
)
|
|
52
|
-
) {
|
|
53
|
-
record = select( coreStore ).getEntityRecord(
|
|
54
|
-
'postType',
|
|
55
|
-
'wp_template',
|
|
56
|
-
getCurrentTemplateId()
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
if ( ! record ) {
|
|
60
|
-
return {};
|
|
61
|
-
}
|
|
62
|
-
const _canEditTemplates = select( coreStore ).canUser( 'create', {
|
|
63
|
-
kind: 'postType',
|
|
64
|
-
name: 'wp_template',
|
|
65
|
-
} );
|
|
66
|
-
return {
|
|
67
|
-
canEditTemplates: _canEditTemplates,
|
|
68
|
-
entity: record,
|
|
69
|
-
onNavigateToEntityRecord:
|
|
70
|
-
getSettings().onNavigateToEntityRecord,
|
|
71
|
-
};
|
|
72
|
-
},
|
|
73
|
-
[ clientId, postContentBlocks ]
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
if ( ! entity ) {
|
|
77
|
-
return (
|
|
78
|
-
<TemplateLockContentOnlyMenuItems
|
|
79
|
-
clientId={ clientId }
|
|
80
|
-
onClose={ onClose }
|
|
81
|
-
/>
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const isPattern = entity.type === 'wp_block';
|
|
86
|
-
let helpText = isPattern
|
|
87
|
-
? __(
|
|
88
|
-
'Edit the pattern to move, delete, or make further changes to this block.'
|
|
89
|
-
)
|
|
90
|
-
: __(
|
|
91
|
-
'Edit the template to move, delete, or make further changes to this block.'
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
if ( ! canEditTemplates ) {
|
|
95
|
-
helpText = __(
|
|
96
|
-
'Only users with permissions to edit the template can move or delete this block'
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return (
|
|
101
|
-
<>
|
|
102
|
-
<BlockSettingsMenuFirstItem>
|
|
103
|
-
<MenuItem
|
|
104
|
-
onClick={ () => {
|
|
105
|
-
onNavigateToEntityRecord( {
|
|
106
|
-
postId: entity.id,
|
|
107
|
-
postType: entity.type,
|
|
108
|
-
} );
|
|
109
|
-
} }
|
|
110
|
-
disabled={ ! canEditTemplates }
|
|
111
|
-
>
|
|
112
|
-
{ isPattern ? __( 'Edit pattern' ) : __( 'Edit template' ) }
|
|
113
|
-
</MenuItem>
|
|
114
|
-
</BlockSettingsMenuFirstItem>
|
|
115
|
-
<Text
|
|
116
|
-
variant="muted"
|
|
117
|
-
as="p"
|
|
118
|
-
className="editor-content-only-settings-menu__description"
|
|
119
|
-
>
|
|
120
|
-
{ helpText }
|
|
121
|
-
</Text>
|
|
122
|
-
</>
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function TemplateLockContentOnlyMenuItems( { clientId, onClose } ) {
|
|
127
|
-
const { contentLockingParent } = useSelect(
|
|
128
|
-
( select ) => {
|
|
129
|
-
const { getContentLockingParent } = unlock(
|
|
130
|
-
select( blockEditorStore )
|
|
131
|
-
);
|
|
132
|
-
return {
|
|
133
|
-
contentLockingParent: getContentLockingParent( clientId ),
|
|
134
|
-
};
|
|
135
|
-
},
|
|
136
|
-
[ clientId ]
|
|
137
|
-
);
|
|
138
|
-
const blockDisplayInformation =
|
|
139
|
-
useBlockDisplayInformation( contentLockingParent );
|
|
140
|
-
const blockEditorActions = useDispatch( blockEditorStore );
|
|
141
|
-
if ( ! blockDisplayInformation?.title ) {
|
|
142
|
-
return null;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const { modifyContentLockBlock } = unlock( blockEditorActions );
|
|
146
|
-
|
|
147
|
-
return (
|
|
148
|
-
<>
|
|
149
|
-
<BlockSettingsMenuFirstItem>
|
|
150
|
-
<MenuItem
|
|
151
|
-
onClick={ () => {
|
|
152
|
-
modifyContentLockBlock( contentLockingParent );
|
|
153
|
-
onClose();
|
|
154
|
-
} }
|
|
155
|
-
>
|
|
156
|
-
{ _x( 'Unlock', 'Unlock content locked blocks' ) }
|
|
157
|
-
</MenuItem>
|
|
158
|
-
</BlockSettingsMenuFirstItem>
|
|
159
|
-
<Text
|
|
160
|
-
variant="muted"
|
|
161
|
-
as="p"
|
|
162
|
-
className="editor-content-only-settings-menu__description"
|
|
163
|
-
>
|
|
164
|
-
{ __(
|
|
165
|
-
'Temporarily unlock the parent block to edit, delete or make further changes to this block.'
|
|
166
|
-
) }
|
|
167
|
-
</Text>
|
|
168
|
-
</>
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export default function ContentOnlySettingsMenu() {
|
|
173
|
-
return (
|
|
174
|
-
<BlockSettingsMenuControls>
|
|
175
|
-
{ ( { selectedClientIds, onClose } ) =>
|
|
176
|
-
selectedClientIds.length === 1 && (
|
|
177
|
-
<ContentOnlySettingsMenuItems
|
|
178
|
-
clientId={ selectedClientIds[ 0 ] }
|
|
179
|
-
onClose={ onClose }
|
|
180
|
-
/>
|
|
181
|
-
)
|
|
182
|
-
}
|
|
183
|
-
</BlockSettingsMenuControls>
|
|
184
|
-
);
|
|
185
|
-
}
|