2024-01-31 07:59:56 -05:00
|
|
|
/******/ (() => { // webpackBootstrap
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/ "use strict";
|
|
|
|
/******/ // The require scope
|
|
|
|
/******/ var __webpack_require__ = {};
|
|
|
|
/******/
|
|
|
|
/************************************************************************/
|
|
|
|
/******/ /* webpack/runtime/define property getters */
|
2024-01-31 07:59:56 -05:00
|
|
|
/******/ (() => {
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/ // define getter functions for harmony exports
|
2024-01-31 07:59:56 -05:00
|
|
|
/******/ __webpack_require__.d = (exports, definition) => {
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/ 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] });
|
|
|
|
/******/ }
|
|
|
|
/******/ }
|
|
|
|
/******/ };
|
2024-01-31 07:59:56 -05:00
|
|
|
/******/ })();
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/
|
|
|
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
2024-01-31 07:59:56 -05:00
|
|
|
/******/ (() => {
|
|
|
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
|
|
/******/ })();
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/
|
|
|
|
/******/ /* webpack/runtime/make namespace object */
|
2024-01-31 07:59:56 -05:00
|
|
|
/******/ (() => {
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/ // define __esModule on exports
|
2024-01-31 07:59:56 -05:00
|
|
|
/******/ __webpack_require__.r = (exports) => {
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
|
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
|
/******/ }
|
|
|
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
2020-10-20 09:36:16 -04:00
|
|
|
/******/ };
|
2024-01-31 07:59:56 -05:00
|
|
|
/******/ })();
|
2022-04-11 08:04:30 -04:00
|
|
|
/******/
|
2020-10-20 09:36:16 -04:00
|
|
|
/************************************************************************/
|
2022-04-11 08:04:30 -04:00
|
|
|
var __webpack_exports__ = {};
|
2020-10-20 09:36:16 -04:00
|
|
|
// ESM COMPAT FLAG
|
|
|
|
__webpack_require__.r(__webpack_exports__);
|
|
|
|
|
|
|
|
// EXPORTS
|
2022-04-11 08:04:30 -04:00
|
|
|
__webpack_require__.d(__webpack_exports__, {
|
2024-01-31 07:59:56 -05:00
|
|
|
ReusableBlocksMenuItems: () => (/* reexport */ ReusableBlocksMenuItems),
|
|
|
|
store: () => (/* reexport */ store)
|
2022-04-11 08:04:30 -04:00
|
|
|
});
|
2020-10-20 09:36:16 -04:00
|
|
|
|
|
|
|
// NAMESPACE OBJECT: ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js
|
|
|
|
var actions_namespaceObject = {};
|
|
|
|
__webpack_require__.r(actions_namespaceObject);
|
2022-04-11 08:04:30 -04:00
|
|
|
__webpack_require__.d(actions_namespaceObject, {
|
2024-01-31 07:59:56 -05:00
|
|
|
__experimentalConvertBlockToStatic: () => (__experimentalConvertBlockToStatic),
|
|
|
|
__experimentalConvertBlocksToReusable: () => (__experimentalConvertBlocksToReusable),
|
|
|
|
__experimentalDeleteReusableBlock: () => (__experimentalDeleteReusableBlock),
|
|
|
|
__experimentalSetEditingReusableBlock: () => (__experimentalSetEditingReusableBlock)
|
2022-04-11 08:04:30 -04:00
|
|
|
});
|
2020-10-20 09:36:16 -04:00
|
|
|
|
|
|
|
// NAMESPACE OBJECT: ./node_modules/@wordpress/reusable-blocks/build-module/store/selectors.js
|
|
|
|
var selectors_namespaceObject = {};
|
|
|
|
__webpack_require__.r(selectors_namespaceObject);
|
2022-04-11 08:04:30 -04:00
|
|
|
__webpack_require__.d(selectors_namespaceObject, {
|
2024-01-31 07:59:56 -05:00
|
|
|
__experimentalIsEditingReusableBlock: () => (__experimentalIsEditingReusableBlock)
|
2022-04-11 08:04:30 -04:00
|
|
|
});
|
2020-10-20 09:36:16 -04:00
|
|
|
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: external ["wp","data"]
|
2024-01-31 07:59:56 -05:00
|
|
|
const external_wp_data_namespaceObject = window["wp"]["data"];
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: external ["wp","blockEditor"]
|
2024-01-31 07:59:56 -05:00
|
|
|
const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: external ["wp","blocks"]
|
2024-01-31 07:59:56 -05:00
|
|
|
const external_wp_blocks_namespaceObject = window["wp"]["blocks"];
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: external ["wp","i18n"]
|
2024-01-31 07:59:56 -05:00
|
|
|
const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js
|
2020-10-20 09:36:16 -04:00
|
|
|
/**
|
|
|
|
* WordPress dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
|
2020-10-20 09:36:16 -04:00
|
|
|
/**
|
|
|
|
* Returns a generator converting a reusable block into a static block.
|
|
|
|
*
|
|
|
|
* @param {string} clientId The client ID of the block to attach.
|
|
|
|
*/
|
2023-06-27 10:24:19 -04:00
|
|
|
const __experimentalConvertBlockToStatic = clientId => ({
|
|
|
|
registry
|
|
|
|
}) => {
|
2022-04-11 08:04:30 -04:00
|
|
|
const oldBlock = registry.select(external_wp_blockEditor_namespaceObject.store).getBlock(clientId);
|
2021-11-08 09:29:21 -05:00
|
|
|
const reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', oldBlock.attributes.ref);
|
2022-09-20 11:43:29 -04:00
|
|
|
const newBlocks = (0,external_wp_blocks_namespaceObject.parse)(typeof reusableBlock.content === 'function' ? reusableBlock.content(reusableBlock) : reusableBlock.content);
|
2022-04-11 08:04:30 -04:00
|
|
|
registry.dispatch(external_wp_blockEditor_namespaceObject.store).replaceBlocks(oldBlock.clientId, newBlocks);
|
2021-11-08 09:29:21 -05:00
|
|
|
};
|
2023-09-26 10:23:26 -04:00
|
|
|
|
2020-10-20 09:36:16 -04:00
|
|
|
/**
|
2023-06-27 10:24:19 -04:00
|
|
|
* Returns a generator converting one or more static blocks into a pattern.
|
2020-10-20 09:36:16 -04:00
|
|
|
*
|
2023-07-18 03:20:48 -04:00
|
|
|
* @param {string[]} clientIds The client IDs of the block to detach.
|
|
|
|
* @param {string} title Pattern title.
|
|
|
|
* @param {undefined|'unsynced'} syncType They way block is synced, current undefined (synced) and 'unsynced'.
|
2020-10-20 09:36:16 -04:00
|
|
|
*/
|
2023-06-27 10:24:19 -04:00
|
|
|
const __experimentalConvertBlocksToReusable = (clientIds, title, syncType) => async ({
|
|
|
|
registry,
|
|
|
|
dispatch
|
|
|
|
}) => {
|
|
|
|
const meta = syncType === 'unsynced' ? {
|
2023-07-07 03:21:17 -04:00
|
|
|
wp_pattern_sync_status: syncType
|
2023-06-27 10:24:19 -04:00
|
|
|
} : undefined;
|
2021-11-08 09:29:21 -05:00
|
|
|
const reusableBlock = {
|
2023-09-26 15:11:22 -04:00
|
|
|
title: title || (0,external_wp_i18n_namespaceObject.__)('Untitled pattern block'),
|
2022-04-11 08:04:30 -04:00
|
|
|
content: (0,external_wp_blocks_namespaceObject.serialize)(registry.select(external_wp_blockEditor_namespaceObject.store).getBlocksByClientId(clientIds)),
|
2023-06-27 10:24:19 -04:00
|
|
|
status: 'publish',
|
|
|
|
meta
|
2021-11-08 09:29:21 -05:00
|
|
|
};
|
|
|
|
const updatedRecord = await registry.dispatch('core').saveEntityRecord('postType', 'wp_block', reusableBlock);
|
2023-06-27 10:24:19 -04:00
|
|
|
if (syncType === 'unsynced') {
|
|
|
|
return;
|
|
|
|
}
|
2022-04-11 08:04:30 -04:00
|
|
|
const newBlock = (0,external_wp_blocks_namespaceObject.createBlock)('core/block', {
|
2021-11-08 09:29:21 -05:00
|
|
|
ref: updatedRecord.id
|
|
|
|
});
|
2022-04-11 08:04:30 -04:00
|
|
|
registry.dispatch(external_wp_blockEditor_namespaceObject.store).replaceBlocks(clientIds, newBlock);
|
2021-11-08 09:29:21 -05:00
|
|
|
dispatch.__experimentalSetEditingReusableBlock(newBlock.clientId, true);
|
|
|
|
};
|
2023-09-26 10:23:26 -04:00
|
|
|
|
2020-10-20 09:36:16 -04:00
|
|
|
/**
|
|
|
|
* Returns a generator deleting a reusable block.
|
|
|
|
*
|
|
|
|
* @param {string} id The ID of the reusable block to delete.
|
|
|
|
*/
|
2023-06-27 10:24:19 -04:00
|
|
|
const __experimentalDeleteReusableBlock = id => async ({
|
|
|
|
registry
|
|
|
|
}) => {
|
2023-09-26 10:23:26 -04:00
|
|
|
const reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', id);
|
2021-11-08 09:29:21 -05:00
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
// Don't allow a reusable block with a temporary ID to be deleted.
|
2021-11-08 09:29:21 -05:00
|
|
|
if (!reusableBlock) {
|
|
|
|
return;
|
2023-09-26 10:23:26 -04:00
|
|
|
}
|
2021-11-08 09:29:21 -05:00
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
// Remove any other blocks that reference this reusable block.
|
2022-04-11 08:04:30 -04: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);
|
2023-09-26 10:23:26 -04:00
|
|
|
const associatedBlockClientIds = associatedBlocks.map(block => block.clientId);
|
2021-11-08 09:29:21 -05:00
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
// Remove the parsed block.
|
2021-11-08 09:29:21 -05:00
|
|
|
if (associatedBlockClientIds.length) {
|
2022-04-11 08:04:30 -04:00
|
|
|
registry.dispatch(external_wp_blockEditor_namespaceObject.store).removeBlocks(associatedBlockClientIds);
|
2021-11-08 09:29:21 -05:00
|
|
|
}
|
|
|
|
await registry.dispatch('core').deleteEntityRecord('postType', 'wp_block', id);
|
|
|
|
};
|
2023-09-26 10:23:26 -04:00
|
|
|
|
2020-10-20 09:36:16 -04:00
|
|
|
/**
|
|
|
|
* Returns an action descriptor for SET_EDITING_REUSABLE_BLOCK action.
|
|
|
|
*
|
2021-11-08 09:29:21 -05:00
|
|
|
* @param {string} clientId The clientID of the reusable block to target.
|
2020-10-20 09:36:16 -04: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-05-19 11:09:27 -04:00
|
|
|
clientId,
|
|
|
|
isEditing
|
2020-10-20 09:36:16 -04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/reducer.js
|
2020-10-20 09:36:16 -04:00
|
|
|
/**
|
|
|
|
* WordPress dependencies
|
|
|
|
*/
|
|
|
|
|
2023-06-27 10:24:19 -04:00
|
|
|
function isEditingReusableBlock(state = {}, action) {
|
|
|
|
if (action?.type === 'SET_EDITING_REUSABLE_BLOCK') {
|
2023-09-26 10:23:26 -04:00
|
|
|
return {
|
|
|
|
...state,
|
2021-05-19 11:09:27 -04:00
|
|
|
[action.clientId]: action.isEditing
|
|
|
|
};
|
2020-10-20 09:36:16 -04:00
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
2024-01-31 07:59:56 -05:00
|
|
|
/* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
|
2021-05-19 11:09:27 -04:00
|
|
|
isEditingReusableBlock
|
2020-10-20 09:36:16 -04:00
|
|
|
}));
|
|
|
|
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/selectors.js
|
2020-10-20 09:36:16 -04:00
|
|
|
/**
|
|
|
|
* Returns true if reusable block is in the editing state.
|
|
|
|
*
|
2021-11-08 09:29:21 -05:00
|
|
|
* @param {Object} state Global application state.
|
2020-10-20 09:36:16 -04: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-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/index.js
|
2020-10-20 09:36:16 -04:00
|
|
|
/**
|
|
|
|
* WordPress dependencies
|
|
|
|
*/
|
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
|
2020-10-20 09:36:16 -04:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-19 11:09:27 -04:00
|
|
|
const STORE_NAME = 'core/reusable-blocks';
|
2023-09-26 10:23:26 -04:00
|
|
|
|
2020-10-20 09:36:16 -04:00
|
|
|
/**
|
2021-01-27 21:04:13 -05:00
|
|
|
* Store definition for the reusable blocks namespace.
|
2020-10-20 09:36:16 -04:00
|
|
|
*
|
2021-02-02 00:17:13 -05:00
|
|
|
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
|
2020-10-20 09:36:16 -04:00
|
|
|
*
|
|
|
|
* @type {Object}
|
|
|
|
*/
|
2022-04-11 08:04:30 -04:00
|
|
|
const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
|
2020-10-20 09:36:16 -04:00
|
|
|
actions: actions_namespaceObject,
|
|
|
|
reducer: reducer,
|
2022-04-12 11:12:47 -04:00
|
|
|
selectors: selectors_namespaceObject
|
2021-01-27 21:04:13 -05:00
|
|
|
});
|
2022-04-11 08:04:30 -04:00
|
|
|
(0,external_wp_data_namespaceObject.register)(store);
|
2020-10-20 09:36:16 -04:00
|
|
|
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: external ["wp","element"]
|
2024-01-31 07:59:56 -05:00
|
|
|
const external_wp_element_namespaceObject = window["wp"]["element"];
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: external ["wp","components"]
|
2024-01-31 07:59:56 -05:00
|
|
|
const external_wp_components_namespaceObject = window["wp"]["components"];
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: external ["wp","primitives"]
|
2024-01-31 07:59:56 -05:00
|
|
|
const external_wp_primitives_namespaceObject = window["wp"]["primitives"];
|
2024-05-31 14:59:00 -04:00
|
|
|
;// CONCATENATED MODULE: external "ReactJSXRuntime"
|
|
|
|
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
|
2022-04-12 11:12:47 -04:00
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol.js
|
2021-05-21 06:14:23 -04:00
|
|
|
/**
|
|
|
|
* WordPress dependencies
|
|
|
|
*/
|
|
|
|
|
2024-05-31 14:59:00 -04:00
|
|
|
|
|
|
|
const symbol = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
|
2021-05-21 06:14:23 -04:00
|
|
|
xmlns: "http://www.w3.org/2000/svg",
|
2024-05-31 14:59:00 -04:00
|
|
|
viewBox: "0 0 24 24",
|
|
|
|
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(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"
|
|
|
|
})
|
|
|
|
});
|
2024-01-31 07:59:56 -05:00
|
|
|
/* harmony default export */ const library_symbol = (symbol);
|
2021-01-27 21:04:13 -05:00
|
|
|
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: external ["wp","notices"]
|
2024-01-31 07:59:56 -05:00
|
|
|
const external_wp_notices_namespaceObject = window["wp"]["notices"];
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: external ["wp","coreData"]
|
2024-01-31 07:59:56 -05:00
|
|
|
const external_wp_coreData_namespaceObject = window["wp"]["coreData"];
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-block-convert-button.js
|
2020-10-20 09:36:16 -04:00
|
|
|
/**
|
|
|
|
* WordPress dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-01-27 21:04:13 -05:00
|
|
|
|
2021-11-08 09:29:21 -05:00
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
|
2020-10-20 09:36:16 -04: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.
|
2023-09-26 10:23:26 -04:00
|
|
|
* @param {()=>void} props.onClose Callback to close the menu.
|
Editor: Update the WordPress packages to the Gutenberg 16.7 RC2 version.
This patch, somewhat small brings a lot to WordPress.
This includes features like:
- DataViews.
- Customization tools like box shadow, background size and repeat.
- UI improvements in the site editor.
- Preferences sharing between the post and site editors.
- Unified panels and editors between post and site editors.
- Improved template mode in the post editor.
- Iterations to multiple interactive blocks.
- Preparing the blocks and UI for pattern overrides.
- and a lot more.
Props luisherranz, gziolo, isabel_brison, costdev, jonsurrell, peterwilsoncc, get_dave, antonvlasenko, desrosj.
See #60315.
Built from https://develop.svn.wordpress.org/trunk@57377
git-svn-id: http://core.svn.wordpress.org/trunk@56883 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-01-29 16:07:12 -05:00
|
|
|
* @return {import('react').ComponentType} The menu control or null.
|
2020-10-20 09:36:16 -04:00
|
|
|
*/
|
2024-09-19 21:55:35 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2023-06-27 10:24:19 -04:00
|
|
|
function ReusableBlockConvertButton({
|
|
|
|
clientIds,
|
2023-09-26 10:23:26 -04:00
|
|
|
rootClientId,
|
|
|
|
onClose
|
2023-06-27 10:24:19 -04:00
|
|
|
}) {
|
2023-07-18 03:20:48 -04:00
|
|
|
const [syncType, setSyncType] = (0,external_wp_element_namespaceObject.useState)(undefined);
|
2022-04-11 08:04:30 -04: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-10-20 09:36:16 -04:00
|
|
|
var _getBlocksByClientId;
|
2021-05-19 11:09:27 -04:00
|
|
|
const {
|
|
|
|
canUser
|
2022-04-11 08:04:30 -04:00
|
|
|
} = select(external_wp_coreData_namespaceObject.store);
|
2021-05-19 11:09:27 -04:00
|
|
|
const {
|
|
|
|
getBlocksByClientId,
|
2023-07-25 04:40:23 -04:00
|
|
|
canInsertBlockType,
|
|
|
|
getBlockRootClientId
|
2022-04-11 08:04:30 -04:00
|
|
|
} = select(external_wp_blockEditor_namespaceObject.store);
|
2023-07-25 04:40:23 -04:00
|
|
|
const rootId = rootClientId || (clientIds.length > 0 ? getBlockRootClientId(clientIds[0]) : undefined);
|
2021-05-19 11:09:27 -04:00
|
|
|
const blocks = (_getBlocksByClientId = getBlocksByClientId(clientIds)) !== null && _getBlocksByClientId !== void 0 ? _getBlocksByClientId : [];
|
2022-04-11 08:04:30 -04: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);
|
2023-09-26 10:23:26 -04:00
|
|
|
const _canConvert =
|
|
|
|
// Hide when this is already a reusable block.
|
|
|
|
!isReusable &&
|
|
|
|
// Hide when reusable blocks are disabled.
|
|
|
|
canInsertBlockType('core/block', rootId) && 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.
|
|
|
|
(0,external_wp_blocks_namespaceObject.hasBlockSupport)(block.name, 'reusable', true)) &&
|
|
|
|
// Hide when current doesn't have permission to do that.
|
2024-09-19 21:55:35 -04:00
|
|
|
// Blocks refers to the wp_block post type, this checks the ability to create a post of that type.
|
|
|
|
!!canUser('create', {
|
|
|
|
kind: 'postType',
|
|
|
|
name: 'wp_block'
|
|
|
|
});
|
2020-10-20 09:36:16 -04:00
|
|
|
return _canConvert;
|
2023-06-27 10:24:19 -04:00
|
|
|
}, [clientIds, rootClientId]);
|
2021-05-19 11:09:27 -04:00
|
|
|
const {
|
|
|
|
__experimentalConvertBlocksToReusable: convertBlocksToReusable
|
2022-04-11 08:04:30 -04:00
|
|
|
} = (0,external_wp_data_namespaceObject.useDispatch)(store);
|
2021-05-19 11:09:27 -04:00
|
|
|
const {
|
|
|
|
createSuccessNotice,
|
|
|
|
createErrorNotice
|
2022-04-11 08:04:30 -04:00
|
|
|
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
|
|
|
|
const onConvert = (0,external_wp_element_namespaceObject.useCallback)(async function (reusableBlockTitle) {
|
2021-05-19 11:09:27 -04:00
|
|
|
try {
|
2023-06-27 10:24:19 -04:00
|
|
|
await convertBlocksToReusable(clientIds, reusableBlockTitle, syncType);
|
2023-09-26 10:23:26 -04:00
|
|
|
createSuccessNotice(!syncType ? (0,external_wp_i18n_namespaceObject.sprintf)(
|
|
|
|
// translators: %s: the name the user has given to the pattern.
|
2023-09-26 15:11:22 -04:00
|
|
|
(0,external_wp_i18n_namespaceObject.__)('Synced pattern created: %s'), reusableBlockTitle) : (0,external_wp_i18n_namespaceObject.sprintf)(
|
2023-09-26 10:23:26 -04:00
|
|
|
// translators: %s: the name the user has given to the pattern.
|
2023-09-26 15:11:22 -04:00
|
|
|
(0,external_wp_i18n_namespaceObject.__)('Unsynced pattern created: %s'), reusableBlockTitle), {
|
2023-07-07 03:21:17 -04:00
|
|
|
type: 'snackbar',
|
|
|
|
id: 'convert-to-reusable-block-success'
|
2021-05-19 11:09:27 -04:00
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
createErrorNotice(error.message, {
|
2023-07-07 03:21:17 -04:00
|
|
|
type: 'snackbar',
|
|
|
|
id: 'convert-to-reusable-block-error'
|
2021-05-19 11:09:27 -04:00
|
|
|
});
|
|
|
|
}
|
2023-06-27 10:24:19 -04:00
|
|
|
}, [convertBlocksToReusable, clientIds, syncType, createSuccessNotice, createErrorNotice]);
|
2020-10-20 09:36:16 -04:00
|
|
|
if (!canConvert) {
|
|
|
|
return null;
|
|
|
|
}
|
2024-05-31 14:59:00 -04:00
|
|
|
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
|
|
|
|
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
|
|
|
|
icon: library_symbol,
|
|
|
|
onClick: () => setIsModalOpen(true),
|
2024-09-19 21:55:35 -04:00
|
|
|
children: (0,external_wp_i18n_namespaceObject.__)('Create pattern')
|
2024-05-31 14:59:00 -04:00
|
|
|
}), isModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
|
|
|
|
title: (0,external_wp_i18n_namespaceObject.__)('Create pattern'),
|
|
|
|
onRequestClose: () => {
|
|
|
|
setIsModalOpen(false);
|
|
|
|
setTitle('');
|
|
|
|
},
|
|
|
|
overlayClassName: "reusable-blocks-menu-items__convert-modal",
|
|
|
|
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
|
|
|
|
onSubmit: event => {
|
|
|
|
event.preventDefault();
|
|
|
|
onConvert(title);
|
|
|
|
setIsModalOpen(false);
|
|
|
|
setTitle('');
|
|
|
|
onClose();
|
|
|
|
},
|
|
|
|
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
|
|
|
|
spacing: "5",
|
2024-09-19 21:55:35 -04:00
|
|
|
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
|
|
|
|
__next40pxDefaultSize: true,
|
2024-05-31 14:59:00 -04:00
|
|
|
__nextHasNoMarginBottom: true,
|
|
|
|
label: (0,external_wp_i18n_namespaceObject.__)('Name'),
|
|
|
|
value: title,
|
|
|
|
onChange: setTitle,
|
|
|
|
placeholder: (0,external_wp_i18n_namespaceObject.__)('My pattern')
|
|
|
|
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToggleControl, {
|
2024-09-19 21:55:35 -04:00
|
|
|
__nextHasNoMarginBottom: true,
|
2024-06-11 06:07:32 -04:00
|
|
|
label: (0,external_wp_i18n_namespaceObject._x)('Synced', 'pattern (singular)'),
|
2024-05-31 14:59:00 -04:00
|
|
|
help: (0,external_wp_i18n_namespaceObject.__)('Sync this pattern across multiple locations.'),
|
|
|
|
checked: !syncType,
|
|
|
|
onChange: () => {
|
|
|
|
setSyncType(!syncType ? 'unsynced' : undefined);
|
|
|
|
}
|
|
|
|
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
|
|
|
|
justify: "right",
|
2024-09-19 21:55:35 -04:00
|
|
|
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button
|
|
|
|
// TODO: Switch to `true` (40px size) if possible
|
|
|
|
, {
|
|
|
|
__next40pxDefaultSize: false,
|
2024-05-31 14:59:00 -04:00
|
|
|
variant: "tertiary",
|
|
|
|
onClick: () => {
|
|
|
|
setIsModalOpen(false);
|
|
|
|
setTitle('');
|
|
|
|
},
|
|
|
|
children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
|
2024-09-19 21:55:35 -04:00
|
|
|
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button
|
|
|
|
// TODO: Switch to `true` (40px size) if possible
|
|
|
|
, {
|
|
|
|
__next40pxDefaultSize: false,
|
2024-05-31 14:59:00 -04:00
|
|
|
variant: "primary",
|
|
|
|
type: "submit",
|
|
|
|
children: (0,external_wp_i18n_namespaceObject.__)('Create')
|
|
|
|
})]
|
|
|
|
})]
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})]
|
|
|
|
});
|
2020-10-20 09:36:16 -04:00
|
|
|
}
|
|
|
|
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: external ["wp","url"]
|
2024-01-31 07:59:56 -05:00
|
|
|
const external_wp_url_namespaceObject = window["wp"]["url"];
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js
|
2020-10-20 09:36:16 -04:00
|
|
|
/**
|
|
|
|
* WordPress dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-09-26 10:23:26 -04:00
|
|
|
|
2021-11-08 09:29:21 -05:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
2024-05-31 14:59:00 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2023-06-27 10:24:19 -04:00
|
|
|
function ReusableBlocksManageButton({
|
|
|
|
clientId
|
|
|
|
}) {
|
2021-05-19 11:09:27 -04:00
|
|
|
const {
|
2022-04-12 11:12:47 -04:00
|
|
|
canRemove,
|
2023-02-07 02:04:52 -05:00
|
|
|
isVisible,
|
2023-07-11 02:59:09 -04:00
|
|
|
managePatternsUrl
|
2022-04-11 08:04:30 -04:00
|
|
|
} = (0,external_wp_data_namespaceObject.useSelect)(select => {
|
2021-05-19 11:09:27 -04:00
|
|
|
const {
|
2022-04-12 11:12:47 -04:00
|
|
|
getBlock,
|
2023-02-07 02:04:52 -05:00
|
|
|
canRemoveBlock,
|
2024-05-23 15:39:28 -04:00
|
|
|
getBlockCount
|
2022-04-11 08:04:30 -04:00
|
|
|
} = select(external_wp_blockEditor_namespaceObject.store);
|
2021-05-19 11:09:27 -04:00
|
|
|
const {
|
|
|
|
canUser
|
2022-04-11 08:04:30 -04:00
|
|
|
} = select(external_wp_coreData_namespaceObject.store);
|
2021-05-19 11:09:27 -04:00
|
|
|
const reusableBlock = getBlock(clientId);
|
2020-10-20 09:36:16 -04:00
|
|
|
return {
|
2022-04-12 11:12:47 -04:00
|
|
|
canRemove: canRemoveBlock(clientId),
|
2024-09-19 21:55:35 -04:00
|
|
|
isVisible: !!reusableBlock && (0,external_wp_blocks_namespaceObject.isReusableBlock)(reusableBlock) && !!canUser('update', {
|
|
|
|
kind: 'postType',
|
|
|
|
name: 'wp_block',
|
|
|
|
id: reusableBlock.attributes.ref
|
|
|
|
}),
|
2023-07-11 02:59:09 -04:00
|
|
|
innerBlockCount: getBlockCount(clientId),
|
|
|
|
// The site editor and templates both check whether the user
|
|
|
|
// has edit_theme_options capabilities. We can leverage that here
|
|
|
|
// and omit the manage patterns link if the user can't access it.
|
2024-09-19 21:55:35 -04:00
|
|
|
managePatternsUrl: canUser('create', {
|
|
|
|
kind: 'postType',
|
|
|
|
name: 'wp_template'
|
|
|
|
}) ? (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', {
|
2023-07-11 02:59:09 -04:00
|
|
|
path: '/patterns'
|
|
|
|
}) : (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', {
|
|
|
|
post_type: 'wp_block'
|
|
|
|
})
|
2020-10-20 09:36:16 -04:00
|
|
|
};
|
2021-05-19 11:09:27 -04:00
|
|
|
}, [clientId]);
|
2021-11-08 09:29:21 -05:00
|
|
|
const {
|
|
|
|
__experimentalConvertBlockToStatic: convertBlockToStatic
|
2022-04-11 08:04:30 -04:00
|
|
|
} = (0,external_wp_data_namespaceObject.useDispatch)(store);
|
2020-10-20 09:36:16 -04:00
|
|
|
if (!isVisible) {
|
|
|
|
return null;
|
|
|
|
}
|
2024-05-31 14:59:00 -04:00
|
|
|
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
|
|
|
|
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
|
|
|
|
href: managePatternsUrl,
|
|
|
|
children: (0,external_wp_i18n_namespaceObject.__)('Manage patterns')
|
|
|
|
}), canRemove && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
|
|
|
|
onClick: () => convertBlockToStatic(clientId),
|
|
|
|
children: (0,external_wp_i18n_namespaceObject.__)('Detach')
|
|
|
|
})]
|
|
|
|
});
|
2020-10-20 09:36:16 -04:00
|
|
|
}
|
2024-01-31 07:59:56 -05:00
|
|
|
/* harmony default export */ const reusable_blocks_manage_button = (ReusableBlocksManageButton);
|
2020-10-20 09:36:16 -04:00
|
|
|
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/index.js
|
2020-10-20 09:36:16 -04:00
|
|
|
/**
|
|
|
|
* WordPress dependencies
|
|
|
|
*/
|
|
|
|
|
2021-05-19 11:09:27 -04:00
|
|
|
|
2020-10-20 09:36:16 -04:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2024-05-31 14:59:00 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2023-06-27 10:24:19 -04:00
|
|
|
function ReusableBlocksMenuItems({
|
|
|
|
rootClientId
|
|
|
|
}) {
|
2024-05-31 14:59:00 -04:00
|
|
|
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, {
|
|
|
|
children: ({
|
|
|
|
onClose,
|
|
|
|
selectedClientIds
|
|
|
|
}) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
|
|
|
|
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ReusableBlockConvertButton, {
|
|
|
|
clientIds: selectedClientIds,
|
|
|
|
rootClientId: rootClientId,
|
|
|
|
onClose: onClose
|
|
|
|
}), selectedClientIds.length === 1 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(reusable_blocks_manage_button, {
|
|
|
|
clientId: selectedClientIds[0]
|
|
|
|
})]
|
|
|
|
})
|
|
|
|
});
|
2020-10-20 09:36:16 -04:00
|
|
|
}
|
|
|
|
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/index.js
|
2021-05-20 08:20:04 -04:00
|
|
|
|
|
|
|
|
2022-04-11 08:04:30 -04:00
|
|
|
;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/index.js
|
2021-05-20 08:20:04 -04:00
|
|
|
|
2020-10-20 09:36:16 -04:00
|
|
|
|
|
|
|
|
2022-04-11 08:04:30 -04:00
|
|
|
(window.wp = window.wp || {}).reusableBlocks = __webpack_exports__;
|
|
|
|
/******/ })()
|
|
|
|
;
|