1 /******/ (function() { // webpackBootstrap |
1 /******/ (() => { // webpackBootstrap |
2 /******/ "use strict"; |
2 /******/ "use strict"; |
3 /******/ // The require scope |
3 /******/ // The require scope |
4 /******/ var __webpack_require__ = {}; |
4 /******/ var __webpack_require__ = {}; |
5 /******/ |
5 /******/ |
6 /************************************************************************/ |
6 /************************************************************************/ |
7 /******/ /* webpack/runtime/define property getters */ |
7 /******/ /* webpack/runtime/define property getters */ |
8 /******/ !function() { |
8 /******/ (() => { |
9 /******/ // define getter functions for harmony exports |
9 /******/ // define getter functions for harmony exports |
10 /******/ __webpack_require__.d = function(exports, definition) { |
10 /******/ __webpack_require__.d = (exports, definition) => { |
11 /******/ for(var key in definition) { |
11 /******/ for(var key in definition) { |
12 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
12 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
13 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
13 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
14 /******/ } |
14 /******/ } |
15 /******/ } |
15 /******/ } |
16 /******/ }; |
16 /******/ }; |
17 /******/ }(); |
17 /******/ })(); |
18 /******/ |
18 /******/ |
19 /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
19 /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
20 /******/ !function() { |
20 /******/ (() => { |
21 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } |
21 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) |
22 /******/ }(); |
22 /******/ })(); |
23 /******/ |
23 /******/ |
24 /******/ /* webpack/runtime/make namespace object */ |
24 /******/ /* webpack/runtime/make namespace object */ |
25 /******/ !function() { |
25 /******/ (() => { |
26 /******/ // define __esModule on exports |
26 /******/ // define __esModule on exports |
27 /******/ __webpack_require__.r = function(exports) { |
27 /******/ __webpack_require__.r = (exports) => { |
28 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
28 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
29 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
29 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
30 /******/ } |
30 /******/ } |
31 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
31 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
32 /******/ }; |
32 /******/ }; |
33 /******/ }(); |
33 /******/ })(); |
34 /******/ |
34 /******/ |
35 /************************************************************************/ |
35 /************************************************************************/ |
36 var __webpack_exports__ = {}; |
36 var __webpack_exports__ = {}; |
37 // ESM COMPAT FLAG |
37 // ESM COMPAT FLAG |
38 __webpack_require__.r(__webpack_exports__); |
38 __webpack_require__.r(__webpack_exports__); |
39 |
39 |
40 // EXPORTS |
40 // EXPORTS |
41 __webpack_require__.d(__webpack_exports__, { |
41 __webpack_require__.d(__webpack_exports__, { |
42 "ReusableBlocksMenuItems": function() { return /* reexport */ reusable_blocks_menu_items; }, |
42 ReusableBlocksMenuItems: () => (/* reexport */ ReusableBlocksMenuItems), |
43 "store": function() { return /* reexport */ store; } |
43 store: () => (/* reexport */ store) |
44 }); |
44 }); |
45 |
45 |
46 // NAMESPACE OBJECT: ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js |
46 // NAMESPACE OBJECT: ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js |
47 var actions_namespaceObject = {}; |
47 var actions_namespaceObject = {}; |
48 __webpack_require__.r(actions_namespaceObject); |
48 __webpack_require__.r(actions_namespaceObject); |
49 __webpack_require__.d(actions_namespaceObject, { |
49 __webpack_require__.d(actions_namespaceObject, { |
50 "__experimentalConvertBlockToStatic": function() { return __experimentalConvertBlockToStatic; }, |
50 __experimentalConvertBlockToStatic: () => (__experimentalConvertBlockToStatic), |
51 "__experimentalConvertBlocksToReusable": function() { return __experimentalConvertBlocksToReusable; }, |
51 __experimentalConvertBlocksToReusable: () => (__experimentalConvertBlocksToReusable), |
52 "__experimentalDeleteReusableBlock": function() { return __experimentalDeleteReusableBlock; }, |
52 __experimentalDeleteReusableBlock: () => (__experimentalDeleteReusableBlock), |
53 "__experimentalSetEditingReusableBlock": function() { return __experimentalSetEditingReusableBlock; } |
53 __experimentalSetEditingReusableBlock: () => (__experimentalSetEditingReusableBlock) |
54 }); |
54 }); |
55 |
55 |
56 // NAMESPACE OBJECT: ./node_modules/@wordpress/reusable-blocks/build-module/store/selectors.js |
56 // NAMESPACE OBJECT: ./node_modules/@wordpress/reusable-blocks/build-module/store/selectors.js |
57 var selectors_namespaceObject = {}; |
57 var selectors_namespaceObject = {}; |
58 __webpack_require__.r(selectors_namespaceObject); |
58 __webpack_require__.r(selectors_namespaceObject); |
59 __webpack_require__.d(selectors_namespaceObject, { |
59 __webpack_require__.d(selectors_namespaceObject, { |
60 "__experimentalIsEditingReusableBlock": function() { return __experimentalIsEditingReusableBlock; } |
60 __experimentalIsEditingReusableBlock: () => (__experimentalIsEditingReusableBlock) |
61 }); |
61 }); |
62 |
62 |
63 ;// CONCATENATED MODULE: external ["wp","data"] |
63 ;// CONCATENATED MODULE: external ["wp","data"] |
64 var external_wp_data_namespaceObject = window["wp"]["data"]; |
64 const external_wp_data_namespaceObject = window["wp"]["data"]; |
65 ;// CONCATENATED MODULE: external "lodash" |
|
66 var external_lodash_namespaceObject = window["lodash"]; |
|
67 ;// CONCATENATED MODULE: external ["wp","blockEditor"] |
65 ;// CONCATENATED MODULE: external ["wp","blockEditor"] |
68 var external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"]; |
66 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"]; |
69 ;// CONCATENATED MODULE: external ["wp","blocks"] |
67 ;// CONCATENATED MODULE: external ["wp","blocks"] |
70 var external_wp_blocks_namespaceObject = window["wp"]["blocks"]; |
68 const external_wp_blocks_namespaceObject = window["wp"]["blocks"]; |
71 ;// CONCATENATED MODULE: external ["wp","i18n"] |
69 ;// CONCATENATED MODULE: external ["wp","i18n"] |
72 var external_wp_i18n_namespaceObject = window["wp"]["i18n"]; |
70 const external_wp_i18n_namespaceObject = window["wp"]["i18n"]; |
73 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js |
71 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js |
74 /** |
72 /** |
75 * External dependencies |
|
76 */ |
|
77 |
|
78 /** |
|
79 * WordPress dependencies |
73 * WordPress dependencies |
80 */ |
74 */ |
81 |
75 |
82 |
76 |
83 |
77 |
85 /** |
79 /** |
86 * Returns a generator converting a reusable block into a static block. |
80 * Returns a generator converting a reusable block into a static block. |
87 * |
81 * |
88 * @param {string} clientId The client ID of the block to attach. |
82 * @param {string} clientId The client ID of the block to attach. |
89 */ |
83 */ |
90 |
84 const __experimentalConvertBlockToStatic = clientId => ({ |
91 const __experimentalConvertBlockToStatic = clientId => _ref => { |
85 registry |
92 let { |
86 }) => { |
93 registry |
|
94 } = _ref; |
|
95 const oldBlock = registry.select(external_wp_blockEditor_namespaceObject.store).getBlock(clientId); |
87 const oldBlock = registry.select(external_wp_blockEditor_namespaceObject.store).getBlock(clientId); |
96 const reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', oldBlock.attributes.ref); |
88 const reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', oldBlock.attributes.ref); |
97 const newBlocks = (0,external_wp_blocks_namespaceObject.parse)((0,external_lodash_namespaceObject.isFunction)(reusableBlock.content) ? reusableBlock.content(reusableBlock) : reusableBlock.content); |
89 const newBlocks = (0,external_wp_blocks_namespaceObject.parse)(typeof reusableBlock.content === 'function' ? reusableBlock.content(reusableBlock) : reusableBlock.content); |
98 registry.dispatch(external_wp_blockEditor_namespaceObject.store).replaceBlocks(oldBlock.clientId, newBlocks); |
90 registry.dispatch(external_wp_blockEditor_namespaceObject.store).replaceBlocks(oldBlock.clientId, newBlocks); |
99 }; |
91 }; |
100 /** |
92 |
101 * Returns a generator converting one or more static blocks into a reusable block. |
93 /** |
102 * |
94 * Returns a generator converting one or more static blocks into a pattern. |
103 * @param {string[]} clientIds The client IDs of the block to detach. |
95 * |
104 * @param {string} title Reusable block title. |
96 * @param {string[]} clientIds The client IDs of the block to detach. |
105 */ |
97 * @param {string} title Pattern title. |
106 |
98 * @param {undefined|'unsynced'} syncType They way block is synced, current undefined (synced) and 'unsynced'. |
107 const __experimentalConvertBlocksToReusable = (clientIds, title) => async _ref2 => { |
99 */ |
108 let { |
100 const __experimentalConvertBlocksToReusable = (clientIds, title, syncType) => async ({ |
109 registry, |
101 registry, |
110 dispatch |
102 dispatch |
111 } = _ref2; |
103 }) => { |
|
104 const meta = syncType === 'unsynced' ? { |
|
105 wp_pattern_sync_status: syncType |
|
106 } : undefined; |
112 const reusableBlock = { |
107 const reusableBlock = { |
113 title: title || (0,external_wp_i18n_namespaceObject.__)('Untitled Reusable block'), |
108 title: title || (0,external_wp_i18n_namespaceObject.__)('Untitled pattern block'), |
114 content: (0,external_wp_blocks_namespaceObject.serialize)(registry.select(external_wp_blockEditor_namespaceObject.store).getBlocksByClientId(clientIds)), |
109 content: (0,external_wp_blocks_namespaceObject.serialize)(registry.select(external_wp_blockEditor_namespaceObject.store).getBlocksByClientId(clientIds)), |
115 status: 'publish' |
110 status: 'publish', |
|
111 meta |
116 }; |
112 }; |
117 const updatedRecord = await registry.dispatch('core').saveEntityRecord('postType', 'wp_block', reusableBlock); |
113 const updatedRecord = await registry.dispatch('core').saveEntityRecord('postType', 'wp_block', reusableBlock); |
|
114 if (syncType === 'unsynced') { |
|
115 return; |
|
116 } |
118 const newBlock = (0,external_wp_blocks_namespaceObject.createBlock)('core/block', { |
117 const newBlock = (0,external_wp_blocks_namespaceObject.createBlock)('core/block', { |
119 ref: updatedRecord.id |
118 ref: updatedRecord.id |
120 }); |
119 }); |
121 registry.dispatch(external_wp_blockEditor_namespaceObject.store).replaceBlocks(clientIds, newBlock); |
120 registry.dispatch(external_wp_blockEditor_namespaceObject.store).replaceBlocks(clientIds, newBlock); |
122 |
|
123 dispatch.__experimentalSetEditingReusableBlock(newBlock.clientId, true); |
121 dispatch.__experimentalSetEditingReusableBlock(newBlock.clientId, true); |
124 }; |
122 }; |
|
123 |
125 /** |
124 /** |
126 * Returns a generator deleting a reusable block. |
125 * Returns a generator deleting a reusable block. |
127 * |
126 * |
128 * @param {string} id The ID of the reusable block to delete. |
127 * @param {string} id The ID of the reusable block to delete. |
129 */ |
128 */ |
130 |
129 const __experimentalDeleteReusableBlock = id => async ({ |
131 const __experimentalDeleteReusableBlock = id => async _ref3 => { |
130 registry |
132 let { |
131 }) => { |
133 registry |
132 const reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', id); |
134 } = _ref3; |
133 |
135 const reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', id); // Don't allow a reusable block with a temporary ID to be deleted. |
134 // Don't allow a reusable block with a temporary ID to be deleted. |
136 |
|
137 if (!reusableBlock) { |
135 if (!reusableBlock) { |
138 return; |
136 return; |
139 } // Remove any other blocks that reference this reusable block. |
137 } |
140 |
138 |
141 |
139 // Remove any other blocks that reference this reusable block. |
142 const allBlocks = registry.select(external_wp_blockEditor_namespaceObject.store).getBlocks(); |
140 const allBlocks = registry.select(external_wp_blockEditor_namespaceObject.store).getBlocks(); |
143 const associatedBlocks = allBlocks.filter(block => (0,external_wp_blocks_namespaceObject.isReusableBlock)(block) && block.attributes.ref === id); |
141 const associatedBlocks = allBlocks.filter(block => (0,external_wp_blocks_namespaceObject.isReusableBlock)(block) && block.attributes.ref === id); |
144 const associatedBlockClientIds = associatedBlocks.map(block => block.clientId); // Remove the parsed block. |
142 const associatedBlockClientIds = associatedBlocks.map(block => block.clientId); |
145 |
143 |
|
144 // Remove the parsed block. |
146 if (associatedBlockClientIds.length) { |
145 if (associatedBlockClientIds.length) { |
147 registry.dispatch(external_wp_blockEditor_namespaceObject.store).removeBlocks(associatedBlockClientIds); |
146 registry.dispatch(external_wp_blockEditor_namespaceObject.store).removeBlocks(associatedBlockClientIds); |
148 } |
147 } |
149 |
|
150 await registry.dispatch('core').deleteEntityRecord('postType', 'wp_block', id); |
148 await registry.dispatch('core').deleteEntityRecord('postType', 'wp_block', id); |
151 }; |
149 }; |
|
150 |
152 /** |
151 /** |
153 * Returns an action descriptor for SET_EDITING_REUSABLE_BLOCK action. |
152 * Returns an action descriptor for SET_EDITING_REUSABLE_BLOCK action. |
154 * |
153 * |
155 * @param {string} clientId The clientID of the reusable block to target. |
154 * @param {string} clientId The clientID of the reusable block to target. |
156 * @param {boolean} isEditing Whether the block should be in editing state. |
155 * @param {boolean} isEditing Whether the block should be in editing state. |
157 * @return {Object} Action descriptor. |
156 * @return {Object} Action descriptor. |
158 */ |
157 */ |
159 |
|
160 function __experimentalSetEditingReusableBlock(clientId, isEditing) { |
158 function __experimentalSetEditingReusableBlock(clientId, isEditing) { |
161 return { |
159 return { |
162 type: 'SET_EDITING_REUSABLE_BLOCK', |
160 type: 'SET_EDITING_REUSABLE_BLOCK', |
163 clientId, |
161 clientId, |
164 isEditing |
162 isEditing |
201 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/index.js |
196 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/index.js |
202 /** |
197 /** |
203 * WordPress dependencies |
198 * WordPress dependencies |
204 */ |
199 */ |
205 |
200 |
|
201 |
206 /** |
202 /** |
207 * Internal dependencies |
203 * Internal dependencies |
208 */ |
204 */ |
209 |
205 |
210 |
206 |
211 |
207 |
212 |
|
213 const STORE_NAME = 'core/reusable-blocks'; |
208 const STORE_NAME = 'core/reusable-blocks'; |
|
209 |
214 /** |
210 /** |
215 * Store definition for the reusable blocks namespace. |
211 * Store definition for the reusable blocks namespace. |
216 * |
212 * |
217 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore |
213 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore |
218 * |
214 * |
219 * @type {Object} |
215 * @type {Object} |
220 */ |
216 */ |
221 |
|
222 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, { |
217 const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, { |
223 actions: actions_namespaceObject, |
218 actions: actions_namespaceObject, |
224 reducer: reducer, |
219 reducer: reducer, |
225 selectors: selectors_namespaceObject |
220 selectors: selectors_namespaceObject |
226 }); |
221 }); |
227 (0,external_wp_data_namespaceObject.register)(store); |
222 (0,external_wp_data_namespaceObject.register)(store); |
228 |
223 |
229 ;// CONCATENATED MODULE: external ["wp","element"] |
224 ;// CONCATENATED MODULE: external ["wp","element"] |
230 var external_wp_element_namespaceObject = window["wp"]["element"]; |
225 const external_wp_element_namespaceObject = window["wp"]["element"]; |
231 ;// CONCATENATED MODULE: external ["wp","components"] |
226 ;// CONCATENATED MODULE: external ["wp","components"] |
232 var external_wp_components_namespaceObject = window["wp"]["components"]; |
227 const external_wp_components_namespaceObject = window["wp"]["components"]; |
233 ;// CONCATENATED MODULE: external ["wp","primitives"] |
228 ;// CONCATENATED MODULE: external ["wp","primitives"] |
234 var external_wp_primitives_namespaceObject = window["wp"]["primitives"]; |
229 const external_wp_primitives_namespaceObject = window["wp"]["primitives"]; |
|
230 ;// CONCATENATED MODULE: external "ReactJSXRuntime" |
|
231 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"]; |
235 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol.js |
232 ;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/symbol.js |
236 |
233 /** |
237 |
234 * WordPress dependencies |
238 /** |
235 */ |
239 * WordPress dependencies |
236 |
240 */ |
237 |
241 |
238 const symbol = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { |
242 const symbol = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
|
243 xmlns: "http://www.w3.org/2000/svg", |
239 xmlns: "http://www.w3.org/2000/svg", |
244 viewBox: "0 0 24 24" |
240 viewBox: "0 0 24 24", |
245 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
241 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { |
246 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" |
242 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" |
247 })); |
243 }) |
248 /* harmony default export */ var library_symbol = (symbol); |
244 }); |
|
245 /* harmony default export */ const library_symbol = (symbol); |
249 |
246 |
250 ;// CONCATENATED MODULE: external ["wp","notices"] |
247 ;// CONCATENATED MODULE: external ["wp","notices"] |
251 var external_wp_notices_namespaceObject = window["wp"]["notices"]; |
248 const external_wp_notices_namespaceObject = window["wp"]["notices"]; |
252 ;// CONCATENATED MODULE: external ["wp","coreData"] |
249 ;// CONCATENATED MODULE: external ["wp","coreData"] |
253 var external_wp_coreData_namespaceObject = window["wp"]["coreData"]; |
250 const external_wp_coreData_namespaceObject = window["wp"]["coreData"]; |
|
251 ;// CONCATENATED MODULE: external ["wp","privateApis"] |
|
252 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"]; |
|
253 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/lock-unlock.js |
|
254 /** |
|
255 * WordPress dependencies |
|
256 */ |
|
257 |
|
258 const { |
|
259 unlock |
|
260 } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/reusable-blocks'); |
|
261 |
254 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-block-convert-button.js |
262 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-block-convert-button.js |
255 |
263 /** |
256 |
264 * WordPress dependencies |
257 /** |
265 */ |
258 * WordPress dependencies |
266 |
259 */ |
|
260 |
267 |
261 |
268 |
262 |
269 |
263 |
270 |
264 |
271 |
268 |
275 |
269 /** |
276 /** |
270 * Internal dependencies |
277 * Internal dependencies |
271 */ |
278 */ |
272 |
279 |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 const { |
|
285 useReusableBlocksRenameHint, |
|
286 ReusableBlocksRenameHint |
|
287 } = unlock(external_wp_blockEditor_namespaceObject.privateApis); |
273 |
288 |
274 /** |
289 /** |
275 * Menu control to convert block(s) to reusable block. |
290 * Menu control to convert block(s) to reusable block. |
276 * |
291 * |
277 * @param {Object} props Component props. |
292 * @param {Object} props Component props. |
278 * @param {string[]} props.clientIds Client ids of selected blocks. |
293 * @param {string[]} props.clientIds Client ids of selected blocks. |
279 * @param {string} props.rootClientId ID of the currently selected top-level block. |
294 * @param {string} props.rootClientId ID of the currently selected top-level block. |
280 * @return {import('@wordpress/element').WPComponent} The menu control or null. |
295 * @param {()=>void} props.onClose Callback to close the menu. |
281 */ |
296 * @return {import('react').ComponentType} The menu control or null. |
282 |
297 */ |
283 function ReusableBlockConvertButton(_ref) { |
298 function ReusableBlockConvertButton({ |
284 let { |
299 clientIds, |
285 clientIds, |
300 rootClientId, |
286 rootClientId |
301 onClose |
287 } = _ref; |
302 }) { |
|
303 const showRenameHint = useReusableBlocksRenameHint(); |
|
304 const [syncType, setSyncType] = (0,external_wp_element_namespaceObject.useState)(undefined); |
288 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); |
305 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false); |
289 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(''); |
306 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(''); |
290 const canConvert = (0,external_wp_data_namespaceObject.useSelect)(select => { |
307 const canConvert = (0,external_wp_data_namespaceObject.useSelect)(select => { |
291 var _getBlocksByClientId; |
308 var _getBlocksByClientId; |
292 |
|
293 const { |
309 const { |
294 canUser |
310 canUser |
295 } = select(external_wp_coreData_namespaceObject.store); |
311 } = select(external_wp_coreData_namespaceObject.store); |
296 const { |
312 const { |
297 getBlocksByClientId, |
313 getBlocksByClientId, |
298 canInsertBlockType |
314 canInsertBlockType, |
|
315 getBlockRootClientId |
299 } = select(external_wp_blockEditor_namespaceObject.store); |
316 } = select(external_wp_blockEditor_namespaceObject.store); |
|
317 const rootId = rootClientId || (clientIds.length > 0 ? getBlockRootClientId(clientIds[0]) : undefined); |
300 const blocks = (_getBlocksByClientId = getBlocksByClientId(clientIds)) !== null && _getBlocksByClientId !== void 0 ? _getBlocksByClientId : []; |
318 const blocks = (_getBlocksByClientId = getBlocksByClientId(clientIds)) !== null && _getBlocksByClientId !== void 0 ? _getBlocksByClientId : []; |
301 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); |
319 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); |
302 |
320 const _canConvert = |
303 const _canConvert = // Hide when this is already a reusable block. |
321 // Hide when this is already a reusable block. |
304 !isReusable && // Hide when reusable blocks are disabled. |
322 !isReusable && |
305 canInsertBlockType('core/block', rootClientId) && blocks.every(block => // Guard against the case where a regular block has *just* been converted. |
323 // Hide when reusable blocks are disabled. |
306 !!block && // Hide on invalid blocks. |
324 canInsertBlockType('core/block', rootId) && blocks.every(block => |
307 block.isValid && // Hide when block doesn't support being made reusable. |
325 // Guard against the case where a regular block has *just* been converted. |
308 (0,external_wp_blocks_namespaceObject.hasBlockSupport)(block.name, 'reusable', true)) && // Hide when current doesn't have permission to do that. |
326 !!block && |
|
327 // Hide on invalid blocks. |
|
328 block.isValid && |
|
329 // Hide when block doesn't support being made reusable. |
|
330 (0,external_wp_blocks_namespaceObject.hasBlockSupport)(block.name, 'reusable', true)) && |
|
331 // Hide when current doesn't have permission to do that. |
309 !!canUser('create', 'blocks'); |
332 !!canUser('create', 'blocks'); |
310 |
|
311 return _canConvert; |
333 return _canConvert; |
312 }, [clientIds]); |
334 }, [clientIds, rootClientId]); |
313 const { |
335 const { |
314 __experimentalConvertBlocksToReusable: convertBlocksToReusable |
336 __experimentalConvertBlocksToReusable: convertBlocksToReusable |
315 } = (0,external_wp_data_namespaceObject.useDispatch)(store); |
337 } = (0,external_wp_data_namespaceObject.useDispatch)(store); |
316 const { |
338 const { |
317 createSuccessNotice, |
339 createSuccessNotice, |
318 createErrorNotice |
340 createErrorNotice |
319 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); |
341 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); |
320 const onConvert = (0,external_wp_element_namespaceObject.useCallback)(async function (reusableBlockTitle) { |
342 const onConvert = (0,external_wp_element_namespaceObject.useCallback)(async function (reusableBlockTitle) { |
321 try { |
343 try { |
322 await convertBlocksToReusable(clientIds, reusableBlockTitle); |
344 await convertBlocksToReusable(clientIds, reusableBlockTitle, syncType); |
323 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Reusable block created.'), { |
345 createSuccessNotice(!syncType ? (0,external_wp_i18n_namespaceObject.sprintf)( |
324 type: 'snackbar' |
346 // translators: %s: the name the user has given to the pattern. |
|
347 (0,external_wp_i18n_namespaceObject.__)('Synced pattern created: %s'), reusableBlockTitle) : (0,external_wp_i18n_namespaceObject.sprintf)( |
|
348 // translators: %s: the name the user has given to the pattern. |
|
349 (0,external_wp_i18n_namespaceObject.__)('Unsynced pattern created: %s'), reusableBlockTitle), { |
|
350 type: 'snackbar', |
|
351 id: 'convert-to-reusable-block-success' |
325 }); |
352 }); |
326 } catch (error) { |
353 } catch (error) { |
327 createErrorNotice(error.message, { |
354 createErrorNotice(error.message, { |
328 type: 'snackbar' |
355 type: 'snackbar', |
|
356 id: 'convert-to-reusable-block-error' |
329 }); |
357 }); |
330 } |
358 } |
331 }, [clientIds]); |
359 }, [convertBlocksToReusable, clientIds, syncType, createSuccessNotice, createErrorNotice]); |
332 |
|
333 if (!canConvert) { |
360 if (!canConvert) { |
334 return null; |
361 return null; |
335 } |
362 } |
336 |
363 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { |
337 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, null, _ref2 => { |
364 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, { |
338 let { |
|
339 onClose |
|
340 } = _ref2; |
|
341 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { |
|
342 icon: library_symbol, |
365 icon: library_symbol, |
343 onClick: () => { |
366 onClick: () => setIsModalOpen(true), |
344 setIsModalOpen(true); |
367 children: showRenameHint ? (0,external_wp_i18n_namespaceObject.__)('Create pattern/reusable block') : (0,external_wp_i18n_namespaceObject.__)('Create pattern') |
345 } |
368 }), isModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, { |
346 }, (0,external_wp_i18n_namespaceObject.__)('Add to Reusable blocks')), isModalOpen && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, { |
369 title: (0,external_wp_i18n_namespaceObject.__)('Create pattern'), |
347 title: (0,external_wp_i18n_namespaceObject.__)('Create Reusable block'), |
|
348 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close'), |
|
349 onRequestClose: () => { |
370 onRequestClose: () => { |
350 setIsModalOpen(false); |
371 setIsModalOpen(false); |
351 setTitle(''); |
372 setTitle(''); |
352 }, |
373 }, |
353 overlayClassName: "reusable-blocks-menu-items__convert-modal" |
374 overlayClassName: "reusable-blocks-menu-items__convert-modal", |
354 }, (0,external_wp_element_namespaceObject.createElement)("form", { |
375 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", { |
355 onSubmit: event => { |
376 onSubmit: event => { |
356 event.preventDefault(); |
377 event.preventDefault(); |
357 onConvert(title); |
378 onConvert(title); |
358 setIsModalOpen(false); |
379 setIsModalOpen(false); |
359 setTitle(''); |
380 setTitle(''); |
360 onClose(); |
381 onClose(); |
361 } |
382 }, |
362 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, { |
383 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, { |
363 label: (0,external_wp_i18n_namespaceObject.__)('Name'), |
384 spacing: "5", |
364 value: title, |
385 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ReusableBlocksRenameHint, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, { |
365 onChange: setTitle |
386 __nextHasNoMarginBottom: true, |
366 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, { |
387 label: (0,external_wp_i18n_namespaceObject.__)('Name'), |
367 className: "reusable-blocks-menu-items__convert-modal-actions", |
388 value: title, |
368 justify: "flex-end" |
389 onChange: setTitle, |
369 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { |
390 placeholder: (0,external_wp_i18n_namespaceObject.__)('My pattern') |
370 variant: "tertiary", |
391 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToggleControl, { |
371 onClick: () => { |
392 label: (0,external_wp_i18n_namespaceObject._x)('Synced', 'pattern (singular)'), |
372 setIsModalOpen(false); |
393 help: (0,external_wp_i18n_namespaceObject.__)('Sync this pattern across multiple locations.'), |
373 setTitle(''); |
394 checked: !syncType, |
374 } |
395 onChange: () => { |
375 }, (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, { |
396 setSyncType(!syncType ? 'unsynced' : undefined); |
376 variant: "primary", |
397 } |
377 type: "submit" |
398 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, { |
378 }, (0,external_wp_i18n_namespaceObject.__)('Save'))))))); |
399 justify: "right", |
|
400 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, { |
|
401 variant: "tertiary", |
|
402 onClick: () => { |
|
403 setIsModalOpen(false); |
|
404 setTitle(''); |
|
405 }, |
|
406 children: (0,external_wp_i18n_namespaceObject.__)('Cancel') |
|
407 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, { |
|
408 variant: "primary", |
|
409 type: "submit", |
|
410 children: (0,external_wp_i18n_namespaceObject.__)('Create') |
|
411 })] |
|
412 })] |
|
413 }) |
|
414 }) |
|
415 })] |
379 }); |
416 }); |
380 } |
417 } |
381 |
418 |
382 ;// CONCATENATED MODULE: external ["wp","url"] |
419 ;// CONCATENATED MODULE: external ["wp","url"] |
383 var external_wp_url_namespaceObject = window["wp"]["url"]; |
420 const external_wp_url_namespaceObject = window["wp"]["url"]; |
384 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js |
421 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js |
385 |
422 /** |
386 |
423 * WordPress dependencies |
387 /** |
424 */ |
388 * WordPress dependencies |
425 |
389 */ |
|
390 |
426 |
391 |
427 |
392 |
428 |
393 |
429 |
394 |
430 |
398 * Internal dependencies |
434 * Internal dependencies |
399 */ |
435 */ |
400 |
436 |
401 |
437 |
402 |
438 |
403 function ReusableBlocksManageButton(_ref) { |
439 |
404 let { |
440 function ReusableBlocksManageButton({ |
405 clientId |
441 clientId |
406 } = _ref; |
442 }) { |
407 const { |
443 const { |
408 canRemove, |
444 canRemove, |
409 isVisible |
445 isVisible, |
|
446 managePatternsUrl |
410 } = (0,external_wp_data_namespaceObject.useSelect)(select => { |
447 } = (0,external_wp_data_namespaceObject.useSelect)(select => { |
411 const { |
448 const { |
412 getBlock, |
449 getBlock, |
413 canRemoveBlock |
450 canRemoveBlock, |
|
451 getBlockCount |
414 } = select(external_wp_blockEditor_namespaceObject.store); |
452 } = select(external_wp_blockEditor_namespaceObject.store); |
415 const { |
453 const { |
416 canUser |
454 canUser |
417 } = select(external_wp_coreData_namespaceObject.store); |
455 } = select(external_wp_coreData_namespaceObject.store); |
418 const reusableBlock = getBlock(clientId); |
456 const reusableBlock = getBlock(clientId); |
419 return { |
457 return { |
420 canRemove: canRemoveBlock(clientId), |
458 canRemove: canRemoveBlock(clientId), |
421 isVisible: !!reusableBlock && (0,external_wp_blocks_namespaceObject.isReusableBlock)(reusableBlock) && !!canUser('update', 'blocks', reusableBlock.attributes.ref) |
459 isVisible: !!reusableBlock && (0,external_wp_blocks_namespaceObject.isReusableBlock)(reusableBlock) && !!canUser('update', 'blocks', reusableBlock.attributes.ref), |
|
460 innerBlockCount: getBlockCount(clientId), |
|
461 // The site editor and templates both check whether the user |
|
462 // has edit_theme_options capabilities. We can leverage that here |
|
463 // and omit the manage patterns link if the user can't access it. |
|
464 managePatternsUrl: canUser('create', 'templates') ? (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', { |
|
465 path: '/patterns' |
|
466 }) : (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', { |
|
467 post_type: 'wp_block' |
|
468 }) |
422 }; |
469 }; |
423 }, [clientId]); |
470 }, [clientId]); |
424 const { |
471 const { |
425 __experimentalConvertBlockToStatic: convertBlockToStatic |
472 __experimentalConvertBlockToStatic: convertBlockToStatic |
426 } = (0,external_wp_data_namespaceObject.useDispatch)(store); |
473 } = (0,external_wp_data_namespaceObject.useDispatch)(store); |
427 |
|
428 if (!isVisible) { |
474 if (!isVisible) { |
429 return null; |
475 return null; |
430 } |
476 } |
431 |
477 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { |
432 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { |
478 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, { |
433 href: (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', { |
479 href: managePatternsUrl, |
434 post_type: 'wp_block' |
480 children: (0,external_wp_i18n_namespaceObject.__)('Manage patterns') |
|
481 }), canRemove && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, { |
|
482 onClick: () => convertBlockToStatic(clientId), |
|
483 children: (0,external_wp_i18n_namespaceObject.__)('Detach') |
|
484 })] |
|
485 }); |
|
486 } |
|
487 /* harmony default export */ const reusable_blocks_manage_button = (ReusableBlocksManageButton); |
|
488 |
|
489 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/index.js |
|
490 /** |
|
491 * WordPress dependencies |
|
492 */ |
|
493 |
|
494 |
|
495 /** |
|
496 * Internal dependencies |
|
497 */ |
|
498 |
|
499 |
|
500 |
|
501 |
|
502 |
|
503 function ReusableBlocksMenuItems({ |
|
504 rootClientId |
|
505 }) { |
|
506 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, { |
|
507 children: ({ |
|
508 onClose, |
|
509 selectedClientIds |
|
510 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { |
|
511 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ReusableBlockConvertButton, { |
|
512 clientIds: selectedClientIds, |
|
513 rootClientId: rootClientId, |
|
514 onClose: onClose |
|
515 }), selectedClientIds.length === 1 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(reusable_blocks_manage_button, { |
|
516 clientId: selectedClientIds[0] |
|
517 })] |
435 }) |
518 }) |
436 }, (0,external_wp_i18n_namespaceObject.__)('Manage Reusable blocks')), canRemove && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.MenuItem, { |
519 }); |
437 onClick: () => convertBlockToStatic(clientId) |
|
438 }, (0,external_wp_i18n_namespaceObject.__)('Convert to regular blocks'))); |
|
439 } |
520 } |
440 |
|
441 /* harmony default export */ var reusable_blocks_manage_button = (ReusableBlocksManageButton); |
|
442 |
|
443 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/index.js |
|
444 |
|
445 |
|
446 /** |
|
447 * WordPress dependencies |
|
448 */ |
|
449 |
|
450 |
|
451 /** |
|
452 * Internal dependencies |
|
453 */ |
|
454 |
|
455 |
|
456 |
|
457 |
|
458 function ReusableBlocksMenuItems(_ref) { |
|
459 let { |
|
460 clientIds, |
|
461 rootClientId |
|
462 } = _ref; |
|
463 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(ReusableBlockConvertButton, { |
|
464 clientIds: clientIds, |
|
465 rootClientId: rootClientId |
|
466 }), clientIds.length === 1 && (0,external_wp_element_namespaceObject.createElement)(reusable_blocks_manage_button, { |
|
467 clientId: clientIds[0] |
|
468 })); |
|
469 } |
|
470 |
|
471 /* harmony default export */ var reusable_blocks_menu_items = ((0,external_wp_data_namespaceObject.withSelect)(select => { |
|
472 const { |
|
473 getSelectedBlockClientIds |
|
474 } = select(external_wp_blockEditor_namespaceObject.store); |
|
475 return { |
|
476 clientIds: getSelectedBlockClientIds() |
|
477 }; |
|
478 })(ReusableBlocksMenuItems)); |
|
479 |
521 |
480 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/index.js |
522 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/index.js |
481 |
523 |
482 |
524 |
483 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/index.js |
525 ;// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/index.js |