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