kollapsminoriteten/wp-includes/js/dist/reusable-blocks.js

489 lines
18 KiB
JavaScript
Raw Normal View History

2022-06-16 14:03:35 +02:00
/******/ (function() { // webpackBootstrap
/******/ "use strict";
/******/ // The require scope
/******/ var __webpack_require__ = {};
/******/
/************************************************************************/
/******/ /* webpack/runtime/define property getters */
/******/ !function() {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = function(exports, definition) {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ }();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ !function() {
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
/******/ }();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ !function() {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
2020-12-10 14:06:04 +01:00
/******/ };
2022-06-16 14:03:35 +02:00
/******/ }();
/******/
2020-12-10 14:06:04 +01:00
/************************************************************************/
2022-06-16 14:03:35 +02:00
var __webpack_exports__ = {};
2020-12-10 14:06:04 +01:00
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXPORTS
2022-06-16 14:03:35 +02:00
__webpack_require__.d(__webpack_exports__, {
"ReusableBlocksMenuItems": function() { return /* reexport */ reusable_blocks_menu_items; },
"store": function() { return /* reexport */ store; }
});
2020-12-10 14:06:04 +01:00
// NAMESPACE OBJECT: ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js
var actions_namespaceObject = {};
__webpack_require__.r(actions_namespaceObject);
2022-06-16 14:03:35 +02:00
__webpack_require__.d(actions_namespaceObject, {
"__experimentalConvertBlockToStatic": function() { return __experimentalConvertBlockToStatic; },
"__experimentalConvertBlocksToReusable": function() { return __experimentalConvertBlocksToReusable; },
"__experimentalDeleteReusableBlock": function() { return __experimentalDeleteReusableBlock; },
"__experimentalSetEditingReusableBlock": function() { return __experimentalSetEditingReusableBlock; }
});
2020-12-10 14:06:04 +01:00
// NAMESPACE OBJECT: ./node_modules/@wordpress/reusable-blocks/build-module/store/selectors.js
var selectors_namespaceObject = {};
__webpack_require__.r(selectors_namespaceObject);
2022-06-16 14:03:35 +02:00
__webpack_require__.d(selectors_namespaceObject, {
"__experimentalIsEditingReusableBlock": function() { return __experimentalIsEditingReusableBlock; }
});
2020-12-10 14:06:04 +01:00
2022-06-16 14:03:35 +02:00
;// CONCATENATED MODULE: external ["wp","data"]
var external_wp_data_namespaceObject = window["wp"]["data"];
;// CONCATENATED MODULE: external "lodash"
var external_lodash_namespaceObject = window["lodash"];
;// CONCATENATED MODULE: external ["wp","blockEditor"]
var external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
;// CONCATENATED MODULE: external ["wp","blocks"]
var external_wp_blocks_namespaceObject = window["wp"]["blocks"];
;// CONCATENATED MODULE: external ["wp","i18n"]
var external_wp_i18n_namespaceObject = window["wp"]["i18n"];
;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js
2021-04-27 08:32:47 +02:00
/**
* External dependencies
*/
2020-12-10 14:06:04 +01:00
/**
* WordPress dependencies
*/
2021-04-27 08:32:47 +02:00
2020-12-10 14:06:04 +01:00
/**
* Returns a generator converting a reusable block into a static block.
*
* @param {string} clientId The client ID of the block to attach.
*/
2022-04-02 10:26:41 +02:00
const __experimentalConvertBlockToStatic = clientId => _ref => {
let {
registry
} = _ref;
2022-06-16 14:03:35 +02:00
const oldBlock = registry.select(external_wp_blockEditor_namespaceObject.store).getBlock(clientId);
2022-04-02 10:26:41 +02:00
const reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', oldBlock.attributes.ref);
2022-06-16 14:03:35 +02:00
const newBlocks = (0,external_wp_blocks_namespaceObject.parse)((0,external_lodash_namespaceObject.isFunction)(reusableBlock.content) ? reusableBlock.content(reusableBlock) : reusableBlock.content);
registry.dispatch(external_wp_blockEditor_namespaceObject.store).replaceBlocks(oldBlock.clientId, newBlocks);
2022-04-02 10:26:41 +02:00
};
2020-12-10 14:06:04 +01:00
/**
* Returns a generator converting one or more static blocks into a reusable block.
*
* @param {string[]} clientIds The client IDs of the block to detach.
2021-07-23 11:58:50 +02:00
* @param {string} title Reusable block title.
2020-12-10 14:06:04 +01:00
*/
2022-04-02 10:26:41 +02:00
const __experimentalConvertBlocksToReusable = (clientIds, title) => async _ref2 => {
let {
registry,
dispatch
} = _ref2;
const reusableBlock = {
2022-06-16 14:03:35 +02:00
title: title || (0,external_wp_i18n_namespaceObject.__)('Untitled Reusable block'),
content: (0,external_wp_blocks_namespaceObject.serialize)(registry.select(external_wp_blockEditor_namespaceObject.store).getBlocksByClientId(clientIds)),
2022-04-02 10:26:41 +02:00
status: 'publish'
};
const updatedRecord = await registry.dispatch('core').saveEntityRecord('postType', 'wp_block', reusableBlock);
2022-06-16 14:03:35 +02:00
const newBlock = (0,external_wp_blocks_namespaceObject.createBlock)('core/block', {
2022-04-02 10:26:41 +02:00
ref: updatedRecord.id
});
2022-06-16 14:03:35 +02:00
registry.dispatch(external_wp_blockEditor_namespaceObject.store).replaceBlocks(clientIds, newBlock);
2022-04-02 10:26:41 +02:00
dispatch.__experimentalSetEditingReusableBlock(newBlock.clientId, true);
};
2020-12-10 14:06:04 +01:00
/**
* Returns a generator deleting a reusable block.
*
* @param {string} id The ID of the reusable block to delete.
*/
2022-04-02 10:26:41 +02:00
const __experimentalDeleteReusableBlock = id => async _ref3 => {
let {
registry
} = _ref3;
2022-06-16 14:03:35 +02:00
const reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', id); // Don't allow a reusable block with a temporary ID to be deleted.
2022-04-02 10:26:41 +02:00
if (!reusableBlock) {
return;
2022-06-16 14:03:35 +02:00
} // Remove any other blocks that reference this reusable block.
2022-04-02 10:26:41 +02:00
2022-06-16 14:03:35 +02:00
const allBlocks = registry.select(external_wp_blockEditor_namespaceObject.store).getBlocks();
const associatedBlocks = allBlocks.filter(block => (0,external_wp_blocks_namespaceObject.isReusableBlock)(block) && block.attributes.ref === id);
2022-04-02 10:26:41 +02:00
const associatedBlockClientIds = associatedBlocks.map(block => block.clientId); // Remove the parsed block.
if (associatedBlockClientIds.length) {
2022-06-16 14:03:35 +02:00
registry.dispatch(external_wp_blockEditor_namespaceObject.store).removeBlocks(associatedBlockClientIds);
2022-04-02 10:26:41 +02:00
}
await registry.dispatch('core').deleteEntityRecord('postType', 'wp_block', id);
};
2020-12-10 14:06:04 +01:00
/**
* Returns an action descriptor for SET_EDITING_REUSABLE_BLOCK action.
*
2022-04-02 10:26:41 +02:00
* @param {string} clientId The clientID of the reusable block to target.
2020-12-10 14:06:04 +01:00
* @param {boolean} isEditing Whether the block should be in editing state.
* @return {Object} Action descriptor.
*/
function __experimentalSetEditingReusableBlock(clientId, isEditing) {
return {
type: 'SET_EDITING_REUSABLE_BLOCK',
2021-07-23 11:58:50 +02:00
clientId,
isEditing
2020-12-10 14:06:04 +01:00
};
}
2022-06-16 14:03:35 +02:00
;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/reducer.js
2020-12-10 14:06:04 +01:00
/**
* WordPress dependencies
*/
2022-04-02 10:26:41 +02:00
function isEditingReusableBlock() {
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
let action = arguments.length > 1 ? arguments[1] : undefined;
2020-12-10 14:06:04 +01:00
if ((action === null || action === void 0 ? void 0 : action.type) === 'SET_EDITING_REUSABLE_BLOCK') {
2021-07-23 11:58:50 +02:00
return { ...state,
[action.clientId]: action.isEditing
};
2020-12-10 14:06:04 +01:00
}
return state;
}
2022-06-16 14:03:35 +02:00
/* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
2021-07-23 11:58:50 +02:00
isEditingReusableBlock
2020-12-10 14:06:04 +01:00
}));
2022-06-16 14:03:35 +02:00
;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/selectors.js
2020-12-10 14:06:04 +01:00
/**
* Returns true if reusable block is in the editing state.
*
2022-04-02 10:26:41 +02:00
* @param {Object} state Global application state.
2020-12-10 14:06:04 +01:00
* @param {number} clientId the clientID of the block.
* @return {boolean} Whether the reusable block is in the editing state.
*/
function __experimentalIsEditingReusableBlock(state, clientId) {
return state.isEditingReusableBlock[clientId];
}
2022-06-16 14:03:35 +02:00
;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/index.js
2020-12-10 14:06:04 +01:00
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
2021-07-23 11:58:50 +02:00
const STORE_NAME = 'core/reusable-blocks';
2020-12-10 14:06:04 +01:00
/**
2021-04-27 08:32:47 +02:00
* Store definition for the reusable blocks namespace.
2020-12-10 14:06:04 +01:00
*
2021-04-27 08:32:47 +02:00
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
2020-12-10 14:06:04 +01:00
*
* @type {Object}
*/
2022-06-16 14:03:35 +02:00
const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
2020-12-10 14:06:04 +01:00
actions: actions_namespaceObject,
reducer: reducer,
2022-06-16 14:03:35 +02:00
selectors: selectors_namespaceObject
2021-04-27 08:32:47 +02:00
});
2022-06-16 14:03:35 +02:00
(0,external_wp_data_namespaceObject.register)(store);
2020-12-10 14:06:04 +01:00
2022-06-16 14:03:35 +02:00
;// CONCATENATED MODULE: external ["wp","element"]
var external_wp_element_namespaceObject = window["wp"]["element"];
;// CONCATENATED MODULE: external ["wp","components"]
var external_wp_components_namespaceObject = window["wp"]["components"];
;// CONCATENATED MODULE: external ["wp","primitives"]
var external_wp_primitives_namespaceObject = window["wp"]["primitives"];
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol.js
2020-12-10 14:06:04 +01:00
/**
* WordPress dependencies
*/
2022-06-16 14:03:35 +02:00
const symbol = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
2020-12-10 14:06:04 +01:00
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
2022-06-16 14:03:35 +02:00
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z"
2020-12-10 14:06:04 +01:00
}));
2022-06-16 14:03:35 +02:00
/* harmony default export */ var library_symbol = (symbol);
2021-04-27 08:32:47 +02:00
2022-06-16 14:03:35 +02:00
;// CONCATENATED MODULE: external ["wp","notices"]
var external_wp_notices_namespaceObject = window["wp"]["notices"];
;// CONCATENATED MODULE: external ["wp","coreData"]
var external_wp_coreData_namespaceObject = window["wp"]["coreData"];
;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-block-convert-button.js
2020-12-10 14:06:04 +01:00
/**
* WordPress dependencies
*/
2021-04-27 08:32:47 +02:00
2022-04-02 10:26:41 +02:00
2020-12-10 14:06:04 +01:00
/**
* Internal dependencies
*/
/**
* Menu control to convert block(s) to reusable block.
*
* @param {Object} props Component props.
* @param {string[]} props.clientIds Client ids of selected blocks.
* @param {string} props.rootClientId ID of the currently selected top-level block.
* @return {import('@wordpress/element').WPComponent} The menu control or null.
*/
2022-04-02 10:26:41 +02:00
function ReusableBlockConvertButton(_ref) {
let {
clientIds,
rootClientId
} = _ref;
2022-06-16 14:03:35 +02:00
const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)('');
const canConvert = (0,external_wp_data_namespaceObject.useSelect)(select => {
2020-12-10 14:06:04 +01:00
var _getBlocksByClientId;
2021-07-23 11:58:50 +02:00
const {
canUser
2022-06-16 14:03:35 +02:00
} = select(external_wp_coreData_namespaceObject.store);
2021-07-23 11:58:50 +02:00
const {
getBlocksByClientId,
canInsertBlockType
2022-06-16 14:03:35 +02:00
} = select(external_wp_blockEditor_namespaceObject.store);
2021-07-23 11:58:50 +02:00
const blocks = (_getBlocksByClientId = getBlocksByClientId(clientIds)) !== null && _getBlocksByClientId !== void 0 ? _getBlocksByClientId : [];
2022-06-16 14:03:35 +02:00
const isReusable = blocks.length === 1 && blocks[0] && (0,external_wp_blocks_namespaceObject.isReusableBlock)(blocks[0]) && !!select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'wp_block', blocks[0].attributes.ref);
2021-07-23 11:58:50 +02:00
const _canConvert = // Hide when this is already a reusable block.
2020-12-10 14:06:04 +01:00
!isReusable && // Hide when reusable blocks are disabled.
2021-07-23 11:58:50 +02:00
canInsertBlockType('core/block', rootClientId) && blocks.every(block => // Guard against the case where a regular block has *just* been converted.
!!block && // Hide on invalid blocks.
block.isValid && // Hide when block doesn't support being made reusable.
2022-06-16 14:03:35 +02:00
(0,external_wp_blocks_namespaceObject.hasBlockSupport)(block.name, 'reusable', true)) && // Hide when current doesn't have permission to do that.
2020-12-10 14:06:04 +01:00
!!canUser('create', 'blocks');
return _canConvert;
}, [clientIds]);
2021-07-23 11:58:50 +02:00
const {
__experimentalConvertBlocksToReusable: convertBlocksToReusable
2022-06-16 14:03:35 +02:00
} = (0,external_wp_data_namespaceObject.useDispatch)(store);
2021-07-23 11:58:50 +02:00
const {
createSuccessNotice,
createErrorNotice
2022-06-16 14:03:35 +02:00
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
const onConvert = (0,external_wp_element_namespaceObject.useCallback)(async function (reusableBlockTitle) {
2021-07-23 11:58:50 +02:00
try {
await convertBlocksToReusable(clientIds, reusableBlockTitle);
2022-06-16 14:03:35 +02:00
createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Reusable block created.'), {
2021-07-23 11:58:50 +02:00
type: 'snackbar'
});
} catch (error) {
createErrorNotice(error.message, {
type: 'snackbar'
});
}
}, [clientIds]);
2020-12-10 14:06:04 +01:00
if (!canConvert) {
return null;
}
2022-06-16 14:03:35 +02:00
return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, null, _ref2 => {
2022-04-02 10:26:41 +02:00
let {
onClose
} = _ref2;
2022-06-16 14:03:35 +02:00
return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
icon: library_symbol,
2022-04-02 10:26:41 +02:00
onClick: () => {
setIsModalOpen(true);
}
2022-06-16 14:03:35 +02:00
}, (0,external_wp_i18n_namespaceObject.__)('Add to Reusable blocks')), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
title: (0,external_wp_i18n_namespaceObject.__)('Create Reusable block'),
closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
2022-04-02 10:26:41 +02:00
onRequestClose: () => {
setIsModalOpen(false);
setTitle('');
},
overlayClassName: "reusable-blocks-menu-items__convert-modal"
2022-06-16 14:03:35 +02:00
}, (0,external_wp_element_namespaceObject.createElement)("form", {
2022-04-02 10:26:41 +02:00
onSubmit: event => {
event.preventDefault();
onConvert(title);
setIsModalOpen(false);
setTitle('');
onClose();
}
2022-06-16 14:03:35 +02:00
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
label: (0,external_wp_i18n_namespaceObject.__)('Name'),
2022-04-02 10:26:41 +02:00
value: title,
onChange: setTitle
2022-06-16 14:03:35 +02:00
}), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
2022-04-02 10:26:41 +02:00
className: "reusable-blocks-menu-items__convert-modal-actions",
justify: "flex-end"
2022-06-16 14:03:35 +02:00
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
variant: "tertiary",
2022-04-02 10:26:41 +02:00
onClick: () => {
setIsModalOpen(false);
setTitle('');
}
2022-06-16 14:03:35 +02:00
}, (0,external_wp_i18n_namespaceObject.__)('Cancel'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
2022-04-02 10:26:41 +02:00
variant: "primary",
type: "submit"
2022-06-16 14:03:35 +02:00
}, (0,external_wp_i18n_namespaceObject.__)('Save')))))));
2022-04-02 10:26:41 +02:00
});
2020-12-10 14:06:04 +01:00
}
2022-06-16 14:03:35 +02:00
;// CONCATENATED MODULE: external ["wp","url"]
var external_wp_url_namespaceObject = window["wp"]["url"];
;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js
2020-12-10 14:06:04 +01:00
/**
* WordPress dependencies
*/
2022-04-02 10:26:41 +02:00
/**
* Internal dependencies
*/
function ReusableBlocksManageButton(_ref) {
let {
clientId
} = _ref;
2021-07-23 11:58:50 +02:00
const {
2022-06-16 14:03:35 +02:00
canRemove,
2021-07-23 11:58:50 +02:00
isVisible
2022-06-16 14:03:35 +02:00
} = (0,external_wp_data_namespaceObject.useSelect)(select => {
2021-07-23 11:58:50 +02:00
const {
2022-06-16 14:03:35 +02:00
getBlock,
canRemoveBlock
} = select(external_wp_blockEditor_namespaceObject.store);
2021-07-23 11:58:50 +02:00
const {
canUser
2022-06-16 14:03:35 +02:00
} = select(external_wp_coreData_namespaceObject.store);
2021-07-23 11:58:50 +02:00
const reusableBlock = getBlock(clientId);
2020-12-10 14:06:04 +01:00
return {
2022-06-16 14:03:35 +02:00
canRemove: canRemoveBlock(clientId),
isVisible: !!reusableBlock && (0,external_wp_blocks_namespaceObject.isReusableBlock)(reusableBlock) && !!canUser('update', 'blocks', reusableBlock.attributes.ref)
2020-12-10 14:06:04 +01:00
};
2021-07-23 11:58:50 +02:00
}, [clientId]);
2022-04-02 10:26:41 +02:00
const {
__experimentalConvertBlockToStatic: convertBlockToStatic
2022-06-16 14:03:35 +02:00
} = (0,external_wp_data_namespaceObject.useDispatch)(store);
2020-12-10 14:06:04 +01:00
if (!isVisible) {
return null;
}
2022-06-16 14:03:35 +02:00
return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
href: (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', {
2021-04-27 08:32:47 +02:00
post_type: 'wp_block'
})
2022-06-16 14:03:35 +02:00
}, (0,external_wp_i18n_namespaceObject.__)('Manage Reusable blocks')), canRemove && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, {
2022-04-02 10:26:41 +02:00
onClick: () => convertBlockToStatic(clientId)
2022-06-16 14:03:35 +02:00
}, (0,external_wp_i18n_namespaceObject.__)('Convert to regular blocks')));
2020-12-10 14:06:04 +01:00
}
2021-04-27 08:32:47 +02:00
/* harmony default export */ var reusable_blocks_manage_button = (ReusableBlocksManageButton);
2020-12-10 14:06:04 +01:00
2022-06-16 14:03:35 +02:00
;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/index.js
2020-12-10 14:06:04 +01:00
/**
* WordPress dependencies
*/
2021-07-23 11:58:50 +02:00
2020-12-10 14:06:04 +01:00
/**
* Internal dependencies
*/
2022-04-02 10:26:41 +02:00
function ReusableBlocksMenuItems(_ref) {
let {
clientIds,
rootClientId
} = _ref;
2022-06-16 14:03:35 +02:00
return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(ReusableBlockConvertButton, {
2020-12-10 14:06:04 +01:00
clientIds: clientIds,
rootClientId: rootClientId
2022-06-16 14:03:35 +02:00
}), clientIds.length === 1 && (0,external_wp_element_namespaceObject.createElement)(reusable_blocks_manage_button, {
2020-12-10 14:06:04 +01:00
clientId: clientIds[0]
}));
}
2022-06-16 14:03:35 +02:00
/* harmony default export */ var reusable_blocks_menu_items = ((0,external_wp_data_namespaceObject.withSelect)(select => {
2021-07-23 11:58:50 +02:00
const {
getSelectedBlockClientIds
2022-06-16 14:03:35 +02:00
} = select(external_wp_blockEditor_namespaceObject.store);
2020-12-10 14:06:04 +01:00
return {
clientIds: getSelectedBlockClientIds()
};
})(ReusableBlocksMenuItems));
2022-06-16 14:03:35 +02:00
;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/index.js
2020-12-10 14:06:04 +01:00
2022-06-16 14:03:35 +02:00
;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/index.js
2020-12-10 14:06:04 +01:00
2022-06-16 14:03:35 +02:00
(window.wp = window.wp || {}).reusableBlocks = __webpack_exports__;
/******/ })()
;