18
|
1 |
this["wp"] = this["wp"] || {}; this["wp"]["reusableBlocks"] = |
|
2 |
/******/ (function(modules) { // webpackBootstrap |
|
3 |
/******/ // The module cache |
|
4 |
/******/ var installedModules = {}; |
|
5 |
/******/ |
|
6 |
/******/ // The require function |
|
7 |
/******/ function __webpack_require__(moduleId) { |
|
8 |
/******/ |
|
9 |
/******/ // Check if module is in cache |
|
10 |
/******/ if(installedModules[moduleId]) { |
|
11 |
/******/ return installedModules[moduleId].exports; |
|
12 |
/******/ } |
|
13 |
/******/ // Create a new module (and put it into the cache) |
|
14 |
/******/ var module = installedModules[moduleId] = { |
|
15 |
/******/ i: moduleId, |
|
16 |
/******/ l: false, |
|
17 |
/******/ exports: {} |
|
18 |
/******/ }; |
|
19 |
/******/ |
|
20 |
/******/ // Execute the module function |
|
21 |
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
|
22 |
/******/ |
|
23 |
/******/ // Flag the module as loaded |
|
24 |
/******/ module.l = true; |
|
25 |
/******/ |
|
26 |
/******/ // Return the exports of the module |
|
27 |
/******/ return module.exports; |
|
28 |
/******/ } |
|
29 |
/******/ |
|
30 |
/******/ |
|
31 |
/******/ // expose the modules object (__webpack_modules__) |
|
32 |
/******/ __webpack_require__.m = modules; |
|
33 |
/******/ |
|
34 |
/******/ // expose the module cache |
|
35 |
/******/ __webpack_require__.c = installedModules; |
|
36 |
/******/ |
|
37 |
/******/ // define getter function for harmony exports |
|
38 |
/******/ __webpack_require__.d = function(exports, name, getter) { |
|
39 |
/******/ if(!__webpack_require__.o(exports, name)) { |
|
40 |
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); |
|
41 |
/******/ } |
|
42 |
/******/ }; |
|
43 |
/******/ |
|
44 |
/******/ // define __esModule on exports |
|
45 |
/******/ __webpack_require__.r = function(exports) { |
|
46 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
|
47 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
|
48 |
/******/ } |
|
49 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
|
50 |
/******/ }; |
|
51 |
/******/ |
|
52 |
/******/ // create a fake namespace object |
|
53 |
/******/ // mode & 1: value is a module id, require it |
|
54 |
/******/ // mode & 2: merge all properties of value into the ns |
|
55 |
/******/ // mode & 4: return value when already ns object |
|
56 |
/******/ // mode & 8|1: behave like require |
|
57 |
/******/ __webpack_require__.t = function(value, mode) { |
|
58 |
/******/ if(mode & 1) value = __webpack_require__(value); |
|
59 |
/******/ if(mode & 8) return value; |
|
60 |
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; |
|
61 |
/******/ var ns = Object.create(null); |
|
62 |
/******/ __webpack_require__.r(ns); |
|
63 |
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); |
|
64 |
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); |
|
65 |
/******/ return ns; |
|
66 |
/******/ }; |
|
67 |
/******/ |
|
68 |
/******/ // getDefaultExport function for compatibility with non-harmony modules |
|
69 |
/******/ __webpack_require__.n = function(module) { |
|
70 |
/******/ var getter = module && module.__esModule ? |
|
71 |
/******/ function getDefault() { return module['default']; } : |
|
72 |
/******/ function getModuleExports() { return module; }; |
|
73 |
/******/ __webpack_require__.d(getter, 'a', getter); |
|
74 |
/******/ return getter; |
|
75 |
/******/ }; |
|
76 |
/******/ |
|
77 |
/******/ // Object.prototype.hasOwnProperty.call |
|
78 |
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; |
|
79 |
/******/ |
|
80 |
/******/ // __webpack_public_path__ |
|
81 |
/******/ __webpack_require__.p = ""; |
|
82 |
/******/ |
|
83 |
/******/ |
|
84 |
/******/ // Load entry module and return exports |
|
85 |
/******/ return __webpack_require__(__webpack_require__.s = "iqm2"); |
|
86 |
/******/ }) |
|
87 |
/************************************************************************/ |
|
88 |
/******/ ({ |
|
89 |
|
|
90 |
/***/ "1ZqX": |
|
91 |
/***/ (function(module, exports) { |
|
92 |
|
|
93 |
(function() { module.exports = window["wp"]["data"]; }()); |
|
94 |
|
|
95 |
/***/ }), |
|
96 |
|
|
97 |
/***/ "GRId": |
|
98 |
/***/ (function(module, exports) { |
|
99 |
|
|
100 |
(function() { module.exports = window["wp"]["element"]; }()); |
|
101 |
|
|
102 |
/***/ }), |
|
103 |
|
|
104 |
/***/ "HSyU": |
|
105 |
/***/ (function(module, exports) { |
|
106 |
|
|
107 |
(function() { module.exports = window["wp"]["blocks"]; }()); |
|
108 |
|
|
109 |
/***/ }), |
|
110 |
|
|
111 |
/***/ "Mmq9": |
|
112 |
/***/ (function(module, exports) { |
|
113 |
|
|
114 |
(function() { module.exports = window["wp"]["url"]; }()); |
|
115 |
|
|
116 |
/***/ }), |
|
117 |
|
|
118 |
/***/ "Tqx9": |
|
119 |
/***/ (function(module, exports) { |
|
120 |
|
|
121 |
(function() { module.exports = window["wp"]["primitives"]; }()); |
|
122 |
|
|
123 |
/***/ }), |
|
124 |
|
|
125 |
/***/ "YLtl": |
|
126 |
/***/ (function(module, exports) { |
|
127 |
|
|
128 |
(function() { module.exports = window["lodash"]; }()); |
|
129 |
|
|
130 |
/***/ }), |
|
131 |
|
|
132 |
/***/ "axFQ": |
|
133 |
/***/ (function(module, exports) { |
|
134 |
|
|
135 |
(function() { module.exports = window["wp"]["blockEditor"]; }()); |
|
136 |
|
|
137 |
/***/ }), |
|
138 |
|
|
139 |
/***/ "iqm2": |
|
140 |
/***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
141 |
|
|
142 |
"use strict"; |
|
143 |
// ESM COMPAT FLAG |
|
144 |
__webpack_require__.r(__webpack_exports__); |
|
145 |
|
|
146 |
// EXPORTS |
|
147 |
__webpack_require__.d(__webpack_exports__, "store", function() { return /* reexport */ store; }); |
|
148 |
__webpack_require__.d(__webpack_exports__, "ReusableBlocksMenuItems", function() { return /* reexport */ reusable_blocks_menu_items; }); |
|
149 |
|
|
150 |
// NAMESPACE OBJECT: ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js |
|
151 |
var actions_namespaceObject = {}; |
|
152 |
__webpack_require__.r(actions_namespaceObject); |
|
153 |
__webpack_require__.d(actions_namespaceObject, "__experimentalConvertBlockToStatic", function() { return __experimentalConvertBlockToStatic; }); |
|
154 |
__webpack_require__.d(actions_namespaceObject, "__experimentalConvertBlocksToReusable", function() { return __experimentalConvertBlocksToReusable; }); |
|
155 |
__webpack_require__.d(actions_namespaceObject, "__experimentalDeleteReusableBlock", function() { return __experimentalDeleteReusableBlock; }); |
|
156 |
__webpack_require__.d(actions_namespaceObject, "__experimentalSetEditingReusableBlock", function() { return __experimentalSetEditingReusableBlock; }); |
|
157 |
|
|
158 |
// NAMESPACE OBJECT: ./node_modules/@wordpress/reusable-blocks/build-module/store/selectors.js |
|
159 |
var selectors_namespaceObject = {}; |
|
160 |
__webpack_require__.r(selectors_namespaceObject); |
|
161 |
__webpack_require__.d(selectors_namespaceObject, "__experimentalIsEditingReusableBlock", function() { return __experimentalIsEditingReusableBlock; }); |
|
162 |
|
|
163 |
// EXTERNAL MODULE: external ["wp","blockEditor"] |
|
164 |
var external_wp_blockEditor_ = __webpack_require__("axFQ"); |
|
165 |
|
|
166 |
// EXTERNAL MODULE: external ["wp","coreData"] |
|
167 |
var external_wp_coreData_ = __webpack_require__("jZUy"); |
|
168 |
|
|
169 |
// EXTERNAL MODULE: external ["wp","data"] |
|
170 |
var external_wp_data_ = __webpack_require__("1ZqX"); |
|
171 |
|
|
172 |
// EXTERNAL MODULE: external "lodash" |
|
173 |
var external_lodash_ = __webpack_require__("YLtl"); |
|
174 |
|
|
175 |
// EXTERNAL MODULE: external ["wp","blocks"] |
|
176 |
var external_wp_blocks_ = __webpack_require__("HSyU"); |
|
177 |
|
|
178 |
// EXTERNAL MODULE: external ["wp","i18n"] |
|
179 |
var external_wp_i18n_ = __webpack_require__("l3Sj"); |
|
180 |
|
|
181 |
// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/controls.js |
|
182 |
/** |
|
183 |
* External dependencies |
|
184 |
*/ |
|
185 |
|
|
186 |
/** |
|
187 |
* WordPress dependencies |
|
188 |
*/ |
|
189 |
|
|
190 |
|
|
191 |
|
|
192 |
|
|
193 |
|
|
194 |
/** |
|
195 |
* Internal dependencies |
|
196 |
*/ |
|
197 |
|
|
198 |
|
|
199 |
/** |
|
200 |
* Convert a reusable block to a static block effect handler |
|
201 |
* |
|
202 |
* @param {string} clientId Block ID. |
|
203 |
* @return {Object} control descriptor. |
|
204 |
*/ |
|
205 |
|
|
206 |
function convertBlockToStatic(clientId) { |
|
207 |
return { |
|
208 |
type: 'CONVERT_BLOCK_TO_STATIC', |
|
209 |
clientId |
|
210 |
}; |
|
211 |
} |
|
212 |
/** |
|
213 |
* Convert a static block to a reusable block effect handler |
|
214 |
* |
|
215 |
* @param {Array} clientIds Block IDs. |
|
216 |
* @param {string} title Reusable block title. |
|
217 |
* @return {Object} control descriptor. |
|
218 |
*/ |
|
219 |
|
|
220 |
function controls_convertBlocksToReusable(clientIds, title) { |
|
221 |
return { |
|
222 |
type: 'CONVERT_BLOCKS_TO_REUSABLE', |
|
223 |
clientIds, |
|
224 |
title |
|
225 |
}; |
|
226 |
} |
|
227 |
/** |
|
228 |
* Deletes a reusable block. |
|
229 |
* |
|
230 |
* @param {string} id Reusable block ID. |
|
231 |
* @return {Object} control descriptor. |
|
232 |
*/ |
|
233 |
|
|
234 |
function deleteReusableBlock(id) { |
|
235 |
return { |
|
236 |
type: 'DELETE_REUSABLE_BLOCK', |
|
237 |
id |
|
238 |
}; |
|
239 |
} |
|
240 |
const controls = { |
|
241 |
CONVERT_BLOCK_TO_STATIC: Object(external_wp_data_["createRegistryControl"])(registry => ({ |
|
242 |
clientId |
|
243 |
}) => { |
|
244 |
const oldBlock = registry.select(external_wp_blockEditor_["store"]).getBlock(clientId); |
|
245 |
const reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', oldBlock.attributes.ref); |
|
246 |
const newBlocks = Object(external_wp_blocks_["parse"])(Object(external_lodash_["isFunction"])(reusableBlock.content) ? reusableBlock.content(reusableBlock) : reusableBlock.content); |
|
247 |
registry.dispatch(external_wp_blockEditor_["store"]).replaceBlocks(oldBlock.clientId, newBlocks); |
|
248 |
}), |
|
249 |
CONVERT_BLOCKS_TO_REUSABLE: Object(external_wp_data_["createRegistryControl"])(registry => async function ({ |
|
250 |
clientIds, |
|
251 |
title |
|
252 |
}) { |
|
253 |
const reusableBlock = { |
|
254 |
title: title || Object(external_wp_i18n_["__"])('Untitled Reusable block'), |
|
255 |
content: Object(external_wp_blocks_["serialize"])(registry.select(external_wp_blockEditor_["store"]).getBlocksByClientId(clientIds)), |
|
256 |
status: 'publish' |
|
257 |
}; |
|
258 |
const updatedRecord = await registry.dispatch('core').saveEntityRecord('postType', 'wp_block', reusableBlock); |
|
259 |
const newBlock = Object(external_wp_blocks_["createBlock"])('core/block', { |
|
260 |
ref: updatedRecord.id |
|
261 |
}); |
|
262 |
registry.dispatch(external_wp_blockEditor_["store"]).replaceBlocks(clientIds, newBlock); |
|
263 |
|
|
264 |
registry.dispatch(store).__experimentalSetEditingReusableBlock(newBlock.clientId, true); |
|
265 |
}), |
|
266 |
DELETE_REUSABLE_BLOCK: Object(external_wp_data_["createRegistryControl"])(registry => async function ({ |
|
267 |
id |
|
268 |
}) { |
|
269 |
const reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', id); // Don't allow a reusable block with a temporary ID to be deleted |
|
270 |
|
|
271 |
if (!reusableBlock) { |
|
272 |
return; |
|
273 |
} // Remove any other blocks that reference this reusable block |
|
274 |
|
|
275 |
|
|
276 |
const allBlocks = registry.select(external_wp_blockEditor_["store"]).getBlocks(); |
|
277 |
const associatedBlocks = allBlocks.filter(block => Object(external_wp_blocks_["isReusableBlock"])(block) && block.attributes.ref === id); |
|
278 |
const associatedBlockClientIds = associatedBlocks.map(block => block.clientId); // Remove the parsed block. |
|
279 |
|
|
280 |
if (associatedBlockClientIds.length) { |
|
281 |
registry.dispatch(external_wp_blockEditor_["store"]).removeBlocks(associatedBlockClientIds); |
|
282 |
} |
|
283 |
|
|
284 |
await registry.dispatch('core').deleteEntityRecord('postType', 'wp_block', id); |
|
285 |
}) |
|
286 |
}; |
|
287 |
/* harmony default export */ var store_controls = (controls); |
|
288 |
|
|
289 |
// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js |
|
290 |
/** |
|
291 |
* Internal dependencies |
|
292 |
*/ |
|
293 |
|
|
294 |
/** |
|
295 |
* Returns a generator converting a reusable block into a static block. |
|
296 |
* |
|
297 |
* @param {string} clientId The client ID of the block to attach. |
|
298 |
*/ |
|
299 |
|
|
300 |
function* __experimentalConvertBlockToStatic(clientId) { |
|
301 |
yield convertBlockToStatic(clientId); |
|
302 |
} |
|
303 |
/** |
|
304 |
* Returns a generator converting one or more static blocks into a reusable block. |
|
305 |
* |
|
306 |
* @param {string[]} clientIds The client IDs of the block to detach. |
|
307 |
* @param {string} title Reusable block title. |
|
308 |
*/ |
|
309 |
|
|
310 |
function* __experimentalConvertBlocksToReusable(clientIds, title) { |
|
311 |
yield controls_convertBlocksToReusable(clientIds, title); |
|
312 |
} |
|
313 |
/** |
|
314 |
* Returns a generator deleting a reusable block. |
|
315 |
* |
|
316 |
* @param {string} id The ID of the reusable block to delete. |
|
317 |
*/ |
|
318 |
|
|
319 |
function* __experimentalDeleteReusableBlock(id) { |
|
320 |
yield deleteReusableBlock(id); |
|
321 |
} |
|
322 |
/** |
|
323 |
* Returns an action descriptor for SET_EDITING_REUSABLE_BLOCK action. |
|
324 |
* |
|
325 |
* @param {string} clientId The clientID of the reusable block to target. |
|
326 |
* @param {boolean} isEditing Whether the block should be in editing state. |
|
327 |
* @return {Object} Action descriptor. |
|
328 |
*/ |
|
329 |
|
|
330 |
function __experimentalSetEditingReusableBlock(clientId, isEditing) { |
|
331 |
return { |
|
332 |
type: 'SET_EDITING_REUSABLE_BLOCK', |
|
333 |
clientId, |
|
334 |
isEditing |
|
335 |
}; |
|
336 |
} |
|
337 |
|
|
338 |
// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/reducer.js |
|
339 |
/** |
|
340 |
* WordPress dependencies |
|
341 |
*/ |
|
342 |
|
|
343 |
function isEditingReusableBlock(state = {}, action) { |
|
344 |
if ((action === null || action === void 0 ? void 0 : action.type) === 'SET_EDITING_REUSABLE_BLOCK') { |
|
345 |
return { ...state, |
|
346 |
[action.clientId]: action.isEditing |
|
347 |
}; |
|
348 |
} |
|
349 |
|
|
350 |
return state; |
|
351 |
} |
|
352 |
/* harmony default export */ var reducer = (Object(external_wp_data_["combineReducers"])({ |
|
353 |
isEditingReusableBlock |
|
354 |
})); |
|
355 |
|
|
356 |
// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/selectors.js |
|
357 |
/** |
|
358 |
* Returns true if reusable block is in the editing state. |
|
359 |
* |
|
360 |
* @param {Object} state Global application state. |
|
361 |
* @param {number} clientId the clientID of the block. |
|
362 |
* @return {boolean} Whether the reusable block is in the editing state. |
|
363 |
*/ |
|
364 |
function __experimentalIsEditingReusableBlock(state, clientId) { |
|
365 |
return state.isEditingReusableBlock[clientId]; |
|
366 |
} |
|
367 |
|
|
368 |
// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/index.js |
|
369 |
/** |
|
370 |
* WordPress dependencies |
|
371 |
*/ |
|
372 |
|
|
373 |
/** |
|
374 |
* Internal dependencies |
|
375 |
*/ |
|
376 |
|
|
377 |
|
|
378 |
|
|
379 |
|
|
380 |
|
|
381 |
const STORE_NAME = 'core/reusable-blocks'; |
|
382 |
/** |
|
383 |
* Store definition for the reusable blocks namespace. |
|
384 |
* |
|
385 |
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore |
|
386 |
* |
|
387 |
* @type {Object} |
|
388 |
*/ |
|
389 |
|
|
390 |
const store = Object(external_wp_data_["createReduxStore"])(STORE_NAME, { |
|
391 |
actions: actions_namespaceObject, |
|
392 |
controls: store_controls, |
|
393 |
reducer: reducer, |
|
394 |
selectors: selectors_namespaceObject |
|
395 |
}); |
|
396 |
Object(external_wp_data_["register"])(store); |
|
397 |
|
|
398 |
// EXTERNAL MODULE: external ["wp","element"] |
|
399 |
var external_wp_element_ = __webpack_require__("GRId"); |
|
400 |
|
|
401 |
// EXTERNAL MODULE: external ["wp","components"] |
|
402 |
var external_wp_components_ = __webpack_require__("tI+e"); |
|
403 |
|
|
404 |
// EXTERNAL MODULE: external ["wp","primitives"] |
|
405 |
var external_wp_primitives_ = __webpack_require__("Tqx9"); |
|
406 |
|
|
407 |
// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/reusable-block.js |
|
408 |
|
|
409 |
|
|
410 |
/** |
|
411 |
* WordPress dependencies |
|
412 |
*/ |
|
413 |
|
|
414 |
const reusable_block_reusableBlock = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], { |
|
415 |
xmlns: "http://www.w3.org/2000/svg", |
|
416 |
viewBox: "0 0 24 24" |
|
417 |
}, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], { |
|
418 |
d: "M7 7.2h8.2L13.5 9l1.1 1.1 3.6-3.6-3.5-4-1.1 1 1.9 2.3H7c-.9 0-1.7.3-2.3.9-1.4 1.5-1.4 4.2-1.4 5.6v.2h1.5v-.3c0-1.1 0-3.5 1-4.5.3-.3.7-.5 1.2-.5zm13.8 4V11h-1.5v.3c0 1.1 0 3.5-1 4.5-.3.3-.7.5-1.3.5H8.8l1.7-1.7-1.1-1.1L5.9 17l3.5 4 1.1-1-1.9-2.3H17c.9 0 1.7-.3 2.3-.9 1.5-1.4 1.5-4.2 1.5-5.6z" |
|
419 |
})); |
|
420 |
/* harmony default export */ var reusable_block = (reusable_block_reusableBlock); |
|
421 |
|
|
422 |
// EXTERNAL MODULE: external ["wp","notices"] |
|
423 |
var external_wp_notices_ = __webpack_require__("onLe"); |
|
424 |
|
|
425 |
// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-block-convert-button.js |
|
426 |
|
|
427 |
|
|
428 |
/** |
|
429 |
* WordPress dependencies |
|
430 |
*/ |
|
431 |
|
|
432 |
|
|
433 |
|
|
434 |
|
|
435 |
|
|
436 |
|
|
437 |
|
|
438 |
|
|
439 |
/** |
|
440 |
* Internal dependencies |
|
441 |
*/ |
|
442 |
|
|
443 |
|
|
444 |
/** |
|
445 |
* Menu control to convert block(s) to reusable block. |
|
446 |
* |
|
447 |
* @param {Object} props Component props. |
|
448 |
* @param {string[]} props.clientIds Client ids of selected blocks. |
|
449 |
* @param {string} props.rootClientId ID of the currently selected top-level block. |
|
450 |
* @return {import('@wordpress/element').WPComponent} The menu control or null. |
|
451 |
*/ |
|
452 |
|
|
453 |
function ReusableBlockConvertButton({ |
|
454 |
clientIds, |
|
455 |
rootClientId |
|
456 |
}) { |
|
457 |
const [isModalOpen, setIsModalOpen] = Object(external_wp_element_["useState"])(false); |
|
458 |
const [title, setTitle] = Object(external_wp_element_["useState"])(''); |
|
459 |
const canConvert = Object(external_wp_data_["useSelect"])(select => { |
|
460 |
var _getBlocksByClientId; |
|
461 |
|
|
462 |
const { |
|
463 |
canUser |
|
464 |
} = select('core'); |
|
465 |
const { |
|
466 |
getBlocksByClientId, |
|
467 |
canInsertBlockType |
|
468 |
} = select('core/block-editor'); |
|
469 |
const blocks = (_getBlocksByClientId = getBlocksByClientId(clientIds)) !== null && _getBlocksByClientId !== void 0 ? _getBlocksByClientId : []; |
|
470 |
const isReusable = blocks.length === 1 && blocks[0] && Object(external_wp_blocks_["isReusableBlock"])(blocks[0]) && !!select('core').getEntityRecord('postType', 'wp_block', blocks[0].attributes.ref); |
|
471 |
|
|
472 |
const _canConvert = // Hide when this is already a reusable block. |
|
473 |
!isReusable && // Hide when reusable blocks are disabled. |
|
474 |
canInsertBlockType('core/block', rootClientId) && blocks.every(block => // Guard against the case where a regular block has *just* been converted. |
|
475 |
!!block && // Hide on invalid blocks. |
|
476 |
block.isValid && // Hide when block doesn't support being made reusable. |
|
477 |
Object(external_wp_blocks_["hasBlockSupport"])(block.name, 'reusable', true)) && // Hide when current doesn't have permission to do that. |
|
478 |
!!canUser('create', 'blocks'); |
|
479 |
|
|
480 |
return _canConvert; |
|
481 |
}, [clientIds]); |
|
482 |
const { |
|
483 |
__experimentalConvertBlocksToReusable: convertBlocksToReusable |
|
484 |
} = Object(external_wp_data_["useDispatch"])(store); |
|
485 |
const { |
|
486 |
createSuccessNotice, |
|
487 |
createErrorNotice |
|
488 |
} = Object(external_wp_data_["useDispatch"])(external_wp_notices_["store"]); |
|
489 |
const onConvert = Object(external_wp_element_["useCallback"])(async function (reusableBlockTitle) { |
|
490 |
try { |
|
491 |
await convertBlocksToReusable(clientIds, reusableBlockTitle); |
|
492 |
createSuccessNotice(Object(external_wp_i18n_["__"])('Reusable block created.'), { |
|
493 |
type: 'snackbar' |
|
494 |
}); |
|
495 |
} catch (error) { |
|
496 |
createErrorNotice(error.message, { |
|
497 |
type: 'snackbar' |
|
498 |
}); |
|
499 |
} |
|
500 |
}, [clientIds]); |
|
501 |
|
|
502 |
if (!canConvert) { |
|
503 |
return null; |
|
504 |
} |
|
505 |
|
|
506 |
return Object(external_wp_element_["createElement"])(external_wp_blockEditor_["BlockSettingsMenuControls"], null, ({ |
|
507 |
onClose |
|
508 |
}) => Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], { |
|
509 |
icon: reusable_block, |
|
510 |
onClick: () => { |
|
511 |
setIsModalOpen(true); |
|
512 |
} |
|
513 |
}, Object(external_wp_i18n_["__"])('Add to Reusable blocks')), isModalOpen && Object(external_wp_element_["createElement"])(external_wp_components_["Modal"], { |
|
514 |
title: Object(external_wp_i18n_["__"])('Create Reusable block'), |
|
515 |
closeLabel: Object(external_wp_i18n_["__"])('Close'), |
|
516 |
onRequestClose: () => { |
|
517 |
setIsModalOpen(false); |
|
518 |
setTitle(''); |
|
519 |
}, |
|
520 |
overlayClassName: "reusable-blocks-menu-items__convert-modal" |
|
521 |
}, Object(external_wp_element_["createElement"])("form", { |
|
522 |
onSubmit: event => { |
|
523 |
event.preventDefault(); |
|
524 |
onConvert(title); |
|
525 |
setIsModalOpen(false); |
|
526 |
setTitle(''); |
|
527 |
onClose(); |
|
528 |
} |
|
529 |
}, Object(external_wp_element_["createElement"])(external_wp_components_["TextControl"], { |
|
530 |
label: Object(external_wp_i18n_["__"])('Name'), |
|
531 |
value: title, |
|
532 |
onChange: setTitle |
|
533 |
}), Object(external_wp_element_["createElement"])(external_wp_components_["Flex"], { |
|
534 |
className: "reusable-blocks-menu-items__convert-modal-actions", |
|
535 |
justify: "flex-end" |
|
536 |
}, Object(external_wp_element_["createElement"])(external_wp_components_["FlexItem"], null, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], { |
|
537 |
isSecondary: true, |
|
538 |
onClick: () => { |
|
539 |
setIsModalOpen(false); |
|
540 |
setTitle(''); |
|
541 |
} |
|
542 |
}, Object(external_wp_i18n_["__"])('Cancel'))), Object(external_wp_element_["createElement"])(external_wp_components_["FlexItem"], null, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], { |
|
543 |
isPrimary: true, |
|
544 |
type: "submit" |
|
545 |
}, Object(external_wp_i18n_["__"])('Save')))))))); |
|
546 |
} |
|
547 |
|
|
548 |
// EXTERNAL MODULE: external ["wp","url"] |
|
549 |
var external_wp_url_ = __webpack_require__("Mmq9"); |
|
550 |
|
|
551 |
// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js |
|
552 |
|
|
553 |
|
|
554 |
/** |
|
555 |
* WordPress dependencies |
|
556 |
*/ |
|
557 |
|
|
558 |
|
|
559 |
|
|
560 |
|
|
561 |
|
|
562 |
|
|
563 |
|
|
564 |
function ReusableBlocksManageButton({ |
|
565 |
clientId |
|
566 |
}) { |
|
567 |
const { |
|
568 |
isVisible |
|
569 |
} = Object(external_wp_data_["useSelect"])(select => { |
|
570 |
const { |
|
571 |
getBlock |
|
572 |
} = select(external_wp_blockEditor_["store"]); |
|
573 |
const { |
|
574 |
canUser |
|
575 |
} = select('core'); |
|
576 |
const reusableBlock = getBlock(clientId); |
|
577 |
return { |
|
578 |
isVisible: !!reusableBlock && Object(external_wp_blocks_["isReusableBlock"])(reusableBlock) && !!canUser('update', 'blocks', reusableBlock.attributes.ref) |
|
579 |
}; |
|
580 |
}, [clientId]); |
|
581 |
|
|
582 |
if (!isVisible) { |
|
583 |
return null; |
|
584 |
} |
|
585 |
|
|
586 |
return Object(external_wp_element_["createElement"])(external_wp_blockEditor_["BlockSettingsMenuControls"], null, Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], { |
|
587 |
href: Object(external_wp_url_["addQueryArgs"])('edit.php', { |
|
588 |
post_type: 'wp_block' |
|
589 |
}) |
|
590 |
}, Object(external_wp_i18n_["__"])('Manage Reusable blocks'))); |
|
591 |
} |
|
592 |
|
|
593 |
/* harmony default export */ var reusable_blocks_manage_button = (ReusableBlocksManageButton); |
|
594 |
|
|
595 |
// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/index.js |
|
596 |
|
|
597 |
|
|
598 |
/** |
|
599 |
* WordPress dependencies |
|
600 |
*/ |
|
601 |
|
|
602 |
|
|
603 |
/** |
|
604 |
* Internal dependencies |
|
605 |
*/ |
|
606 |
|
|
607 |
|
|
608 |
|
|
609 |
|
|
610 |
function ReusableBlocksMenuItems({ |
|
611 |
clientIds, |
|
612 |
rootClientId |
|
613 |
}) { |
|
614 |
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(ReusableBlockConvertButton, { |
|
615 |
clientIds: clientIds, |
|
616 |
rootClientId: rootClientId |
|
617 |
}), clientIds.length === 1 && Object(external_wp_element_["createElement"])(reusable_blocks_manage_button, { |
|
618 |
clientId: clientIds[0] |
|
619 |
})); |
|
620 |
} |
|
621 |
|
|
622 |
/* harmony default export */ var reusable_blocks_menu_items = (Object(external_wp_data_["withSelect"])(select => { |
|
623 |
const { |
|
624 |
getSelectedBlockClientIds |
|
625 |
} = select(external_wp_blockEditor_["store"]); |
|
626 |
return { |
|
627 |
clientIds: getSelectedBlockClientIds() |
|
628 |
}; |
|
629 |
})(ReusableBlocksMenuItems)); |
|
630 |
|
|
631 |
// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/index.js |
|
632 |
|
|
633 |
|
|
634 |
// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/index.js |
|
635 |
/** |
|
636 |
* WordPress dependencies |
|
637 |
*/ |
|
638 |
|
|
639 |
|
|
640 |
|
|
641 |
|
|
642 |
|
|
643 |
|
|
644 |
/***/ }), |
|
645 |
|
|
646 |
/***/ "jZUy": |
|
647 |
/***/ (function(module, exports) { |
|
648 |
|
|
649 |
(function() { module.exports = window["wp"]["coreData"]; }()); |
|
650 |
|
|
651 |
/***/ }), |
|
652 |
|
|
653 |
/***/ "l3Sj": |
|
654 |
/***/ (function(module, exports) { |
|
655 |
|
|
656 |
(function() { module.exports = window["wp"]["i18n"]; }()); |
|
657 |
|
|
658 |
/***/ }), |
|
659 |
|
|
660 |
/***/ "onLe": |
|
661 |
/***/ (function(module, exports) { |
|
662 |
|
|
663 |
(function() { module.exports = window["wp"]["notices"]; }()); |
|
664 |
|
|
665 |
/***/ }), |
|
666 |
|
|
667 |
/***/ "tI+e": |
|
668 |
/***/ (function(module, exports) { |
|
669 |
|
|
670 |
(function() { module.exports = window["wp"]["components"]; }()); |
|
671 |
|
|
672 |
/***/ }) |
|
673 |
|
|
674 |
/******/ }); |