19
|
1 |
/******/ (function() { // webpackBootstrap |
|
2 |
/******/ "use strict"; |
|
3 |
/******/ // The require scope |
|
4 |
/******/ var __webpack_require__ = {}; |
|
5 |
/******/ |
|
6 |
/************************************************************************/ |
|
7 |
/******/ /* webpack/runtime/compat get default export */ |
|
8 |
/******/ !function() { |
|
9 |
/******/ // getDefaultExport function for compatibility with non-harmony modules |
|
10 |
/******/ __webpack_require__.n = function(module) { |
|
11 |
/******/ var getter = module && module.__esModule ? |
|
12 |
/******/ function() { return module['default']; } : |
|
13 |
/******/ function() { return module; }; |
|
14 |
/******/ __webpack_require__.d(getter, { a: getter }); |
|
15 |
/******/ return getter; |
16
|
16 |
/******/ }; |
19
|
17 |
/******/ }(); |
|
18 |
/******/ |
|
19 |
/******/ /* webpack/runtime/define property getters */ |
|
20 |
/******/ !function() { |
|
21 |
/******/ // define getter functions for harmony exports |
|
22 |
/******/ __webpack_require__.d = function(exports, definition) { |
|
23 |
/******/ for(var key in definition) { |
|
24 |
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
|
25 |
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
|
26 |
/******/ } |
|
27 |
/******/ } |
|
28 |
/******/ }; |
|
29 |
/******/ }(); |
|
30 |
/******/ |
|
31 |
/******/ /* webpack/runtime/hasOwnProperty shorthand */ |
|
32 |
/******/ !function() { |
|
33 |
/******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } |
|
34 |
/******/ }(); |
|
35 |
/******/ |
|
36 |
/******/ /* webpack/runtime/make namespace object */ |
|
37 |
/******/ !function() { |
|
38 |
/******/ // define __esModule on exports |
|
39 |
/******/ __webpack_require__.r = function(exports) { |
|
40 |
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
|
41 |
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
|
42 |
/******/ } |
|
43 |
/******/ Object.defineProperty(exports, '__esModule', { value: true }); |
|
44 |
/******/ }; |
|
45 |
/******/ }(); |
|
46 |
/******/ |
16
|
47 |
/************************************************************************/ |
19
|
48 |
var __webpack_exports__ = {}; |
16
|
49 |
// ESM COMPAT FLAG |
|
50 |
__webpack_require__.r(__webpack_exports__); |
|
51 |
|
18
|
52 |
// EXPORTS |
19
|
53 |
__webpack_require__.d(__webpack_exports__, { |
|
54 |
"store": function() { return /* reexport */ store; } |
|
55 |
}); |
18
|
56 |
|
16
|
57 |
// NAMESPACE OBJECT: ./node_modules/@wordpress/block-directory/build-module/store/selectors.js |
|
58 |
var selectors_namespaceObject = {}; |
|
59 |
__webpack_require__.r(selectors_namespaceObject); |
19
|
60 |
__webpack_require__.d(selectors_namespaceObject, { |
|
61 |
"getDownloadableBlocks": function() { return getDownloadableBlocks; }, |
|
62 |
"getErrorNoticeForBlock": function() { return getErrorNoticeForBlock; }, |
|
63 |
"getErrorNotices": function() { return getErrorNotices; }, |
|
64 |
"getInstalledBlockTypes": function() { return getInstalledBlockTypes; }, |
|
65 |
"getNewBlockTypes": function() { return getNewBlockTypes; }, |
|
66 |
"getUnusedBlockTypes": function() { return getUnusedBlockTypes; }, |
|
67 |
"isInstalling": function() { return isInstalling; }, |
|
68 |
"isRequestingDownloadableBlocks": function() { return isRequestingDownloadableBlocks; } |
|
69 |
}); |
16
|
70 |
|
|
71 |
// NAMESPACE OBJECT: ./node_modules/@wordpress/block-directory/build-module/store/actions.js |
|
72 |
var actions_namespaceObject = {}; |
|
73 |
__webpack_require__.r(actions_namespaceObject); |
19
|
74 |
__webpack_require__.d(actions_namespaceObject, { |
|
75 |
"addInstalledBlockType": function() { return addInstalledBlockType; }, |
|
76 |
"clearErrorNotice": function() { return clearErrorNotice; }, |
|
77 |
"fetchDownloadableBlocks": function() { return fetchDownloadableBlocks; }, |
|
78 |
"installBlockType": function() { return installBlockType; }, |
|
79 |
"receiveDownloadableBlocks": function() { return receiveDownloadableBlocks; }, |
|
80 |
"removeInstalledBlockType": function() { return removeInstalledBlockType; }, |
|
81 |
"setErrorNotice": function() { return setErrorNotice; }, |
|
82 |
"setIsInstalling": function() { return setIsInstalling; }, |
|
83 |
"uninstallBlockType": function() { return uninstallBlockType; } |
|
84 |
}); |
16
|
85 |
|
19
|
86 |
// NAMESPACE OBJECT: ./node_modules/@wordpress/block-directory/build-module/store/resolvers.js |
|
87 |
var resolvers_namespaceObject = {}; |
|
88 |
__webpack_require__.r(resolvers_namespaceObject); |
|
89 |
__webpack_require__.d(resolvers_namespaceObject, { |
|
90 |
"getDownloadableBlocks": function() { return resolvers_getDownloadableBlocks; } |
|
91 |
}); |
18
|
92 |
|
19
|
93 |
;// CONCATENATED MODULE: external ["wp","element"] |
|
94 |
var external_wp_element_namespaceObject = window["wp"]["element"]; |
|
95 |
;// CONCATENATED MODULE: external ["wp","plugins"] |
|
96 |
var external_wp_plugins_namespaceObject = window["wp"]["plugins"]; |
|
97 |
;// CONCATENATED MODULE: external ["wp","hooks"] |
|
98 |
var external_wp_hooks_namespaceObject = window["wp"]["hooks"]; |
|
99 |
;// CONCATENATED MODULE: external ["wp","blocks"] |
|
100 |
var external_wp_blocks_namespaceObject = window["wp"]["blocks"]; |
|
101 |
;// CONCATENATED MODULE: external ["wp","data"] |
|
102 |
var external_wp_data_namespaceObject = window["wp"]["data"]; |
|
103 |
;// CONCATENATED MODULE: external ["wp","editor"] |
|
104 |
var external_wp_editor_namespaceObject = window["wp"]["editor"]; |
|
105 |
;// CONCATENATED MODULE: external "lodash" |
|
106 |
var external_lodash_namespaceObject = window["lodash"]; |
|
107 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/reducer.js |
16
|
108 |
/** |
|
109 |
* External dependencies |
|
110 |
*/ |
|
111 |
|
|
112 |
/** |
|
113 |
* WordPress dependencies |
|
114 |
*/ |
|
115 |
|
|
116 |
|
|
117 |
/** |
|
118 |
* Reducer returning an array of downloadable blocks. |
|
119 |
* |
|
120 |
* @param {Object} state Current state. |
|
121 |
* @param {Object} action Dispatched action. |
|
122 |
* |
|
123 |
* @return {Object} Updated state. |
|
124 |
*/ |
|
125 |
|
19
|
126 |
const downloadableBlocks = function () { |
|
127 |
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
128 |
let action = arguments.length > 1 ? arguments[1] : undefined; |
|
129 |
|
16
|
130 |
switch (action.type) { |
|
131 |
case 'FETCH_DOWNLOADABLE_BLOCKS': |
18
|
132 |
return { ...state, |
|
133 |
[action.filterValue]: { |
|
134 |
isRequesting: true |
|
135 |
} |
|
136 |
}; |
16
|
137 |
|
|
138 |
case 'RECEIVE_DOWNLOADABLE_BLOCKS': |
18
|
139 |
return { ...state, |
|
140 |
[action.filterValue]: { |
|
141 |
results: action.downloadableBlocks, |
|
142 |
isRequesting: false |
|
143 |
} |
|
144 |
}; |
16
|
145 |
} |
|
146 |
|
|
147 |
return state; |
|
148 |
}; |
|
149 |
/** |
|
150 |
* Reducer managing the installation and deletion of blocks. |
|
151 |
* |
|
152 |
* @param {Object} state Current state. |
|
153 |
* @param {Object} action Dispatched action. |
|
154 |
* |
|
155 |
* @return {Object} Updated state. |
|
156 |
*/ |
|
157 |
|
19
|
158 |
const blockManagement = function () { |
|
159 |
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { |
|
160 |
installedBlockTypes: [], |
|
161 |
isInstalling: {} |
|
162 |
}; |
|
163 |
let action = arguments.length > 1 ? arguments[1] : undefined; |
|
164 |
|
16
|
165 |
switch (action.type) { |
|
166 |
case 'ADD_INSTALLED_BLOCK_TYPE': |
18
|
167 |
return { ...state, |
|
168 |
installedBlockTypes: [...state.installedBlockTypes, action.item] |
|
169 |
}; |
16
|
170 |
|
|
171 |
case 'REMOVE_INSTALLED_BLOCK_TYPE': |
18
|
172 |
return { ...state, |
|
173 |
installedBlockTypes: state.installedBlockTypes.filter(blockType => blockType.name !== action.item.name) |
|
174 |
}; |
16
|
175 |
|
|
176 |
case 'SET_INSTALLING_BLOCK': |
18
|
177 |
return { ...state, |
|
178 |
isInstalling: { ...state.isInstalling, |
|
179 |
[action.blockId]: action.isInstalling |
|
180 |
} |
|
181 |
}; |
16
|
182 |
} |
|
183 |
|
|
184 |
return state; |
|
185 |
}; |
|
186 |
/** |
|
187 |
* Reducer returning an object of error notices. |
|
188 |
* |
|
189 |
* @param {Object} state Current state. |
|
190 |
* @param {Object} action Dispatched action. |
|
191 |
* |
|
192 |
* @return {Object} Updated state. |
|
193 |
*/ |
|
194 |
|
19
|
195 |
const errorNotices = function () { |
|
196 |
let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
197 |
let action = arguments.length > 1 ? arguments[1] : undefined; |
|
198 |
|
16
|
199 |
switch (action.type) { |
|
200 |
case 'SET_ERROR_NOTICE': |
18
|
201 |
return { ...state, |
|
202 |
[action.blockId]: { |
|
203 |
message: action.message, |
|
204 |
isFatal: action.isFatal |
|
205 |
} |
|
206 |
}; |
16
|
207 |
|
|
208 |
case 'CLEAR_ERROR_NOTICE': |
19
|
209 |
return (0,external_lodash_namespaceObject.omit)(state, action.blockId); |
16
|
210 |
} |
|
211 |
|
|
212 |
return state; |
|
213 |
}; |
19
|
214 |
/* harmony default export */ var reducer = ((0,external_wp_data_namespaceObject.combineReducers)({ |
18
|
215 |
downloadableBlocks, |
|
216 |
blockManagement, |
|
217 |
errorNotices |
16
|
218 |
})); |
|
219 |
|
19
|
220 |
;// CONCATENATED MODULE: external ["wp","blockEditor"] |
|
221 |
var external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"]; |
|
222 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/utils/has-block-type.js |
16
|
223 |
/** |
|
224 |
* Check if a block list contains a specific block type. Recursively searches |
|
225 |
* through `innerBlocks` if they exist. |
|
226 |
* |
19
|
227 |
* @param {Object} blockType A block object to search for. |
|
228 |
* @param {Object[]} blocks The list of blocks to look through. |
16
|
229 |
* |
|
230 |
* @return {boolean} Whether the blockType is found. |
|
231 |
*/ |
19
|
232 |
function hasBlockType(blockType) { |
|
233 |
let blocks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; |
|
234 |
|
16
|
235 |
if (!blocks.length) { |
|
236 |
return false; |
|
237 |
} |
|
238 |
|
19
|
239 |
if (blocks.some(_ref => { |
|
240 |
let { |
|
241 |
name |
|
242 |
} = _ref; |
|
243 |
return name === blockType.name; |
|
244 |
})) { |
16
|
245 |
return true; |
|
246 |
} |
|
247 |
|
18
|
248 |
for (let i = 0; i < blocks.length; i++) { |
16
|
249 |
if (hasBlockType(blockType, blocks[i].innerBlocks)) { |
|
250 |
return true; |
|
251 |
} |
|
252 |
} |
|
253 |
|
|
254 |
return false; |
|
255 |
} |
|
256 |
|
19
|
257 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/selectors.js |
16
|
258 |
/** |
|
259 |
* WordPress dependencies |
|
260 |
*/ |
|
261 |
|
18
|
262 |
|
16
|
263 |
/** |
|
264 |
* Internal dependencies |
|
265 |
*/ |
|
266 |
|
|
267 |
|
|
268 |
/** |
|
269 |
* Returns true if application is requesting for downloadable blocks. |
|
270 |
* |
18
|
271 |
* @param {Object} state Global application state. |
16
|
272 |
* @param {string} filterValue Search string. |
|
273 |
* |
18
|
274 |
* @return {boolean} Whether a request is in progress for the blocks list. |
16
|
275 |
*/ |
|
276 |
|
19
|
277 |
function isRequestingDownloadableBlocks(state, filterValue) { |
|
278 |
var _state$downloadableBl, _state$downloadableBl2; |
16
|
279 |
|
19
|
280 |
return (_state$downloadableBl = (_state$downloadableBl2 = state.downloadableBlocks[filterValue]) === null || _state$downloadableBl2 === void 0 ? void 0 : _state$downloadableBl2.isRequesting) !== null && _state$downloadableBl !== void 0 ? _state$downloadableBl : false; |
16
|
281 |
} |
|
282 |
/** |
18
|
283 |
* Returns the available uninstalled blocks. |
16
|
284 |
* |
|
285 |
* @param {Object} state Global application state. |
|
286 |
* @param {string} filterValue Search string. |
|
287 |
* |
18
|
288 |
* @return {Array} Downloadable blocks. |
16
|
289 |
*/ |
|
290 |
|
19
|
291 |
function getDownloadableBlocks(state, filterValue) { |
|
292 |
var _state$downloadableBl3, _state$downloadableBl4; |
16
|
293 |
|
19
|
294 |
return (_state$downloadableBl3 = (_state$downloadableBl4 = state.downloadableBlocks[filterValue]) === null || _state$downloadableBl4 === void 0 ? void 0 : _state$downloadableBl4.results) !== null && _state$downloadableBl3 !== void 0 ? _state$downloadableBl3 : []; |
16
|
295 |
} |
|
296 |
/** |
18
|
297 |
* Returns the block types that have been installed on the server in this |
|
298 |
* session. |
16
|
299 |
* |
|
300 |
* @param {Object} state Global application state. |
|
301 |
* |
18
|
302 |
* @return {Array} Block type items |
16
|
303 |
*/ |
|
304 |
|
|
305 |
function getInstalledBlockTypes(state) { |
|
306 |
return state.blockManagement.installedBlockTypes; |
|
307 |
} |
|
308 |
/** |
|
309 |
* Returns block types that have been installed on the server and used in the |
|
310 |
* current post. |
|
311 |
* |
|
312 |
* @param {Object} state Global application state. |
|
313 |
* |
|
314 |
* @return {Array} Block type items. |
|
315 |
*/ |
|
316 |
|
19
|
317 |
const getNewBlockTypes = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => { |
|
318 |
const usedBlockTree = select(external_wp_blockEditor_namespaceObject.store).getBlocks(); |
18
|
319 |
const installedBlockTypes = getInstalledBlockTypes(state); |
|
320 |
return installedBlockTypes.filter(blockType => hasBlockType(blockType, usedBlockTree)); |
16
|
321 |
}); |
|
322 |
/** |
|
323 |
* Returns the block types that have been installed on the server but are not |
|
324 |
* used in the current post. |
|
325 |
* |
|
326 |
* @param {Object} state Global application state. |
|
327 |
* |
|
328 |
* @return {Array} Block type items. |
|
329 |
*/ |
|
330 |
|
19
|
331 |
const getUnusedBlockTypes = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => { |
|
332 |
const usedBlockTree = select(external_wp_blockEditor_namespaceObject.store).getBlocks(); |
18
|
333 |
const installedBlockTypes = getInstalledBlockTypes(state); |
|
334 |
return installedBlockTypes.filter(blockType => !hasBlockType(blockType, usedBlockTree)); |
16
|
335 |
}); |
|
336 |
/** |
18
|
337 |
* Returns true if a block plugin install is in progress. |
16
|
338 |
* |
18
|
339 |
* @param {Object} state Global application state. |
16
|
340 |
* @param {string} blockId Id of the block. |
|
341 |
* |
18
|
342 |
* @return {boolean} Whether this block is currently being installed. |
16
|
343 |
*/ |
|
344 |
|
19
|
345 |
function isInstalling(state, blockId) { |
16
|
346 |
return state.blockManagement.isInstalling[blockId] || false; |
|
347 |
} |
|
348 |
/** |
18
|
349 |
* Returns all block error notices. |
16
|
350 |
* |
|
351 |
* @param {Object} state Global application state. |
|
352 |
* |
|
353 |
* @return {Object} Object with error notices. |
|
354 |
*/ |
|
355 |
|
|
356 |
function getErrorNotices(state) { |
|
357 |
return state.errorNotices; |
|
358 |
} |
|
359 |
/** |
|
360 |
* Returns the error notice for a given block. |
|
361 |
* |
|
362 |
* @param {Object} state Global application state. |
|
363 |
* @param {string} blockId The ID of the block plugin. eg: my-block |
|
364 |
* |
|
365 |
* @return {string|boolean} The error text, or false if no error. |
|
366 |
*/ |
|
367 |
|
19
|
368 |
function getErrorNoticeForBlock(state, blockId) { |
16
|
369 |
return state.errorNotices[blockId]; |
|
370 |
} |
|
371 |
|
19
|
372 |
;// CONCATENATED MODULE: external ["wp","i18n"] |
|
373 |
var external_wp_i18n_namespaceObject = window["wp"]["i18n"]; |
|
374 |
;// CONCATENATED MODULE: external ["wp","apiFetch"] |
|
375 |
var external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"]; |
|
376 |
var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject); |
|
377 |
;// CONCATENATED MODULE: external ["wp","notices"] |
|
378 |
var external_wp_notices_namespaceObject = window["wp"]["notices"]; |
|
379 |
;// CONCATENATED MODULE: external ["wp","url"] |
|
380 |
var external_wp_url_namespaceObject = window["wp"]["url"]; |
|
381 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/load-assets.js |
16
|
382 |
/** |
|
383 |
* WordPress dependencies |
|
384 |
*/ |
|
385 |
|
|
386 |
/** |
|
387 |
* Load an asset for a block. |
|
388 |
* |
|
389 |
* This function returns a Promise that will resolve once the asset is loaded, |
18
|
390 |
* or in the case of Stylesheets and Inline JavaScript, will resolve immediately. |
16
|
391 |
* |
|
392 |
* @param {HTMLElement} el A HTML Element asset to inject. |
|
393 |
* |
|
394 |
* @return {Promise} Promise which will resolve when the asset is loaded. |
|
395 |
*/ |
|
396 |
|
18
|
397 |
const loadAsset = el => { |
|
398 |
return new Promise((resolve, reject) => { |
16
|
399 |
/* |
|
400 |
* Reconstruct the passed element, this is required as inserting the Node directly |
|
401 |
* won't always fire the required onload events, even if the asset wasn't already loaded. |
|
402 |
*/ |
18
|
403 |
const newNode = document.createElement(el.nodeName); |
|
404 |
['id', 'rel', 'src', 'href', 'type'].forEach(attr => { |
16
|
405 |
if (el[attr]) { |
|
406 |
newNode[attr] = el[attr]; |
|
407 |
} |
|
408 |
}); // Append inline <script> contents. |
|
409 |
|
|
410 |
if (el.innerHTML) { |
|
411 |
newNode.appendChild(document.createTextNode(el.innerHTML)); |
|
412 |
} |
|
413 |
|
18
|
414 |
newNode.onload = () => resolve(true); |
16
|
415 |
|
18
|
416 |
newNode.onerror = () => reject(new Error('Error loading asset.')); |
16
|
417 |
|
|
418 |
document.body.appendChild(newNode); // Resolve Stylesheets and Inline JavaScript immediately. |
|
419 |
|
|
420 |
if ('link' === newNode.nodeName.toLowerCase() || 'script' === newNode.nodeName.toLowerCase() && !newNode.src) { |
|
421 |
resolve(); |
|
422 |
} |
|
423 |
}); |
|
424 |
}; |
|
425 |
/** |
|
426 |
* Load the asset files for a block |
|
427 |
*/ |
|
428 |
|
19
|
429 |
async function loadAssets() { |
|
430 |
/* |
|
431 |
* Fetch the current URL (post-new.php, or post.php?post=1&action=edit) and compare the |
|
432 |
* JavaScript and CSS assets loaded between the pages. This imports the required assets |
|
433 |
* for the block into the current page while not requiring that we know them up-front. |
|
434 |
* In the future this can be improved by reliance upon block.json and/or a script-loader |
|
435 |
* dependency API. |
|
436 |
*/ |
|
437 |
const response = await external_wp_apiFetch_default()({ |
|
438 |
url: document.location.href, |
|
439 |
parse: false |
|
440 |
}); |
|
441 |
const data = await response.text(); |
|
442 |
const doc = new window.DOMParser().parseFromString(data, 'text/html'); |
|
443 |
const newAssets = Array.from(doc.querySelectorAll('link[rel="stylesheet"],script')).filter(asset => asset.id && !document.getElementById(asset.id)); |
|
444 |
/* |
|
445 |
* Load each asset in order, as they may depend upon an earlier loaded script. |
|
446 |
* Stylesheets and Inline Scripts will resolve immediately upon insertion. |
|
447 |
*/ |
|
448 |
|
|
449 |
for (const newAsset of newAssets) { |
|
450 |
await loadAsset(newAsset); |
|
451 |
} |
16
|
452 |
} |
|
453 |
|
19
|
454 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/utils/get-plugin-url.js |
16
|
455 |
/** |
|
456 |
* Get the plugin's direct API link out of a block-directory response. |
|
457 |
* |
|
458 |
* @param {Object} block The block object |
|
459 |
* |
|
460 |
* @return {string} The plugin URL, if exists. |
|
461 |
*/ |
|
462 |
function getPluginUrl(block) { |
|
463 |
if (!block) { |
|
464 |
return false; |
|
465 |
} |
|
466 |
|
18
|
467 |
const link = block.links['wp:plugin'] || block.links.self; |
16
|
468 |
|
|
469 |
if (link && link.length) { |
|
470 |
return link[0].href; |
|
471 |
} |
|
472 |
|
|
473 |
return false; |
|
474 |
} |
|
475 |
|
19
|
476 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/actions.js |
|
477 |
/** |
|
478 |
* External dependencies |
|
479 |
*/ |
|
480 |
|
18
|
481 |
/** |
|
482 |
* WordPress dependencies |
|
483 |
*/ |
16
|
484 |
|
|
485 |
|
|
486 |
|
|
487 |
|
|
488 |
|
19
|
489 |
|
16
|
490 |
/** |
|
491 |
* Internal dependencies |
|
492 |
*/ |
|
493 |
|
|
494 |
|
|
495 |
|
|
496 |
/** |
|
497 |
* Returns an action object used in signalling that the downloadable blocks |
18
|
498 |
* have been requested and are loading. |
16
|
499 |
* |
|
500 |
* @param {string} filterValue Search string. |
|
501 |
* |
|
502 |
* @return {Object} Action object. |
|
503 |
*/ |
|
504 |
|
|
505 |
function fetchDownloadableBlocks(filterValue) { |
|
506 |
return { |
|
507 |
type: 'FETCH_DOWNLOADABLE_BLOCKS', |
18
|
508 |
filterValue |
16
|
509 |
}; |
|
510 |
} |
|
511 |
/** |
|
512 |
* Returns an action object used in signalling that the downloadable blocks |
|
513 |
* have been updated. |
|
514 |
* |
|
515 |
* @param {Array} downloadableBlocks Downloadable blocks. |
|
516 |
* @param {string} filterValue Search string. |
|
517 |
* |
|
518 |
* @return {Object} Action object. |
|
519 |
*/ |
|
520 |
|
|
521 |
function receiveDownloadableBlocks(downloadableBlocks, filterValue) { |
|
522 |
return { |
|
523 |
type: 'RECEIVE_DOWNLOADABLE_BLOCKS', |
18
|
524 |
downloadableBlocks, |
|
525 |
filterValue |
16
|
526 |
}; |
|
527 |
} |
|
528 |
/** |
|
529 |
* Action triggered to install a block plugin. |
|
530 |
* |
|
531 |
* @param {Object} block The block item returned by search. |
|
532 |
* |
|
533 |
* @return {boolean} Whether the block was successfully installed & loaded. |
|
534 |
*/ |
|
535 |
|
19
|
536 |
const installBlockType = block => async _ref => { |
|
537 |
let { |
|
538 |
registry, |
|
539 |
dispatch |
|
540 |
} = _ref; |
18
|
541 |
const { |
|
542 |
id, |
19
|
543 |
name |
18
|
544 |
} = block; |
|
545 |
let success = false; |
19
|
546 |
dispatch.clearErrorNotice(id); |
16
|
547 |
|
18
|
548 |
try { |
19
|
549 |
dispatch.setIsInstalling(id, true); // If we have a wp:plugin link, the plugin is installed but inactive. |
16
|
550 |
|
18
|
551 |
const url = getPluginUrl(block); |
|
552 |
let links = {}; |
16
|
553 |
|
18
|
554 |
if (url) { |
19
|
555 |
await external_wp_apiFetch_default()({ |
|
556 |
method: 'PUT', |
18
|
557 |
url, |
|
558 |
data: { |
|
559 |
status: 'active' |
19
|
560 |
} |
18
|
561 |
}); |
|
562 |
} else { |
19
|
563 |
const response = await external_wp_apiFetch_default()({ |
|
564 |
method: 'POST', |
18
|
565 |
path: 'wp/v2/plugins', |
|
566 |
data: { |
19
|
567 |
slug: id, |
18
|
568 |
status: 'active' |
19
|
569 |
} |
18
|
570 |
}); // Add the `self` link for newly-installed blocks. |
16
|
571 |
|
18
|
572 |
links = response._links; |
|
573 |
} |
16
|
574 |
|
19
|
575 |
dispatch.addInstalledBlockType({ ...block, |
18
|
576 |
links: { ...block.links, |
|
577 |
...links |
|
578 |
} |
19
|
579 |
}); // Ensures that the block metadata is propagated to the editor when registered on the server. |
|
580 |
|
|
581 |
const metadataFields = ['api_version', 'title', 'category', 'parent', 'icon', 'description', 'keywords', 'attributes', 'provides_context', 'uses_context', 'supports', 'styles', 'example', 'variations']; |
|
582 |
await external_wp_apiFetch_default()({ |
|
583 |
path: (0,external_wp_url_namespaceObject.addQueryArgs)(`/wp/v2/block-types/${name}`, { |
|
584 |
_fields: metadataFields |
|
585 |
}) |
|
586 |
}) // Ignore when the block is not registered on the server. |
|
587 |
.catch(() => {}).then(response => { |
|
588 |
if (!response) { |
|
589 |
return; |
|
590 |
} |
|
591 |
|
|
592 |
(0,external_wp_blocks_namespaceObject.unstable__bootstrapServerSideBlockDefinitions)({ |
|
593 |
[name]: (0,external_lodash_namespaceObject.pick)(response, metadataFields) |
|
594 |
}); |
18
|
595 |
}); |
19
|
596 |
await loadAssets(); |
|
597 |
const registeredBlocks = registry.select(external_wp_blocks_namespaceObject.store).getBlockTypes(); |
16
|
598 |
|
19
|
599 |
if (!registeredBlocks.some(i => i.name === name)) { |
|
600 |
throw new Error((0,external_wp_i18n_namespaceObject.__)('Error registering block. Try reloading the page.')); |
18
|
601 |
} |
16
|
602 |
|
19
|
603 |
registry.dispatch(external_wp_notices_namespaceObject.store).createInfoNotice((0,external_wp_i18n_namespaceObject.sprintf)( // translators: %s is the block title. |
|
604 |
(0,external_wp_i18n_namespaceObject.__)('Block %s installed and added.'), block.title), { |
18
|
605 |
speak: true, |
|
606 |
type: 'snackbar' |
|
607 |
}); |
|
608 |
success = true; |
|
609 |
} catch (error) { |
19
|
610 |
let message = error.message || (0,external_wp_i18n_namespaceObject.__)('An error occurred.'); // Errors we throw are fatal. |
16
|
611 |
|
|
612 |
|
19
|
613 |
let isFatal = error instanceof Error; // Specific API errors that are fatal. |
16
|
614 |
|
18
|
615 |
const fatalAPIErrors = { |
19
|
616 |
folder_exists: (0,external_wp_i18n_namespaceObject.__)('This block is already installed. Try reloading the page.'), |
|
617 |
unable_to_connect_to_filesystem: (0,external_wp_i18n_namespaceObject.__)('Error installing block. You can reload the page and try again.') |
18
|
618 |
}; |
16
|
619 |
|
18
|
620 |
if (fatalAPIErrors[error.code]) { |
|
621 |
isFatal = true; |
|
622 |
message = fatalAPIErrors[error.code]; |
|
623 |
} |
16
|
624 |
|
19
|
625 |
dispatch.setErrorNotice(id, message, isFatal); |
|
626 |
registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(message, { |
18
|
627 |
speak: true, |
|
628 |
isDismissible: true |
|
629 |
}); |
|
630 |
} |
16
|
631 |
|
19
|
632 |
dispatch.setIsInstalling(id, false); |
18
|
633 |
return success; |
19
|
634 |
}; |
16
|
635 |
/** |
|
636 |
* Action triggered to uninstall a block plugin. |
|
637 |
* |
|
638 |
* @param {Object} block The blockType object. |
|
639 |
*/ |
|
640 |
|
19
|
641 |
const uninstallBlockType = block => async _ref2 => { |
|
642 |
let { |
|
643 |
registry, |
|
644 |
dispatch |
|
645 |
} = _ref2; |
|
646 |
|
18
|
647 |
try { |
19
|
648 |
const url = getPluginUrl(block); |
|
649 |
await external_wp_apiFetch_default()({ |
|
650 |
method: 'PUT', |
|
651 |
url, |
18
|
652 |
data: { |
|
653 |
status: 'inactive' |
19
|
654 |
} |
|
655 |
}); |
|
656 |
await external_wp_apiFetch_default()({ |
|
657 |
method: 'DELETE', |
|
658 |
url |
18
|
659 |
}); |
19
|
660 |
dispatch.removeInstalledBlockType(block); |
18
|
661 |
} catch (error) { |
19
|
662 |
registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(error.message || (0,external_wp_i18n_namespaceObject.__)('An error occurred.')); |
18
|
663 |
} |
19
|
664 |
}; |
16
|
665 |
/** |
18
|
666 |
* Returns an action object used to add a block type to the "newly installed" |
|
667 |
* tracking list. |
16
|
668 |
* |
|
669 |
* @param {Object} item The block item with the block id and name. |
|
670 |
* |
|
671 |
* @return {Object} Action object. |
|
672 |
*/ |
|
673 |
|
|
674 |
function addInstalledBlockType(item) { |
|
675 |
return { |
|
676 |
type: 'ADD_INSTALLED_BLOCK_TYPE', |
18
|
677 |
item |
16
|
678 |
}; |
|
679 |
} |
|
680 |
/** |
18
|
681 |
* Returns an action object used to remove a block type from the "newly installed" |
|
682 |
* tracking list. |
16
|
683 |
* |
|
684 |
* @param {string} item The block item with the block id and name. |
|
685 |
* |
|
686 |
* @return {Object} Action object. |
|
687 |
*/ |
|
688 |
|
|
689 |
function removeInstalledBlockType(item) { |
|
690 |
return { |
|
691 |
type: 'REMOVE_INSTALLED_BLOCK_TYPE', |
18
|
692 |
item |
16
|
693 |
}; |
|
694 |
} |
|
695 |
/** |
18
|
696 |
* Returns an action object used to indicate install in progress. |
16
|
697 |
* |
19
|
698 |
* @param {string} blockId |
16
|
699 |
* @param {boolean} isInstalling |
|
700 |
* |
|
701 |
* @return {Object} Action object. |
|
702 |
*/ |
|
703 |
|
|
704 |
function setIsInstalling(blockId, isInstalling) { |
|
705 |
return { |
|
706 |
type: 'SET_INSTALLING_BLOCK', |
18
|
707 |
blockId, |
|
708 |
isInstalling |
16
|
709 |
}; |
|
710 |
} |
|
711 |
/** |
18
|
712 |
* Sets an error notice to be displayed to the user for a given block. |
16
|
713 |
* |
19
|
714 |
* @param {string} blockId The ID of the block plugin. eg: my-block |
|
715 |
* @param {string} message The message shown in the notice. |
18
|
716 |
* @param {boolean} isFatal Whether the user can recover from the error. |
16
|
717 |
* |
|
718 |
* @return {Object} Action object. |
|
719 |
*/ |
|
720 |
|
19
|
721 |
function setErrorNotice(blockId, message) { |
|
722 |
let isFatal = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; |
16
|
723 |
return { |
|
724 |
type: 'SET_ERROR_NOTICE', |
18
|
725 |
blockId, |
|
726 |
message, |
|
727 |
isFatal |
16
|
728 |
}; |
|
729 |
} |
|
730 |
/** |
18
|
731 |
* Sets the error notice to empty for specific block. |
16
|
732 |
* |
|
733 |
* @param {string} blockId The ID of the block plugin. eg: my-block |
|
734 |
* |
|
735 |
* @return {Object} Action object. |
|
736 |
*/ |
|
737 |
|
|
738 |
function clearErrorNotice(blockId) { |
|
739 |
return { |
|
740 |
type: 'CLEAR_ERROR_NOTICE', |
18
|
741 |
blockId |
16
|
742 |
}; |
|
743 |
} |
|
744 |
|
19
|
745 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/resolvers.js |
16
|
746 |
/** |
|
747 |
* External dependencies |
|
748 |
*/ |
|
749 |
|
|
750 |
/** |
|
751 |
* WordPress dependencies |
|
752 |
*/ |
|
753 |
|
|
754 |
|
|
755 |
/** |
|
756 |
* Internal dependencies |
|
757 |
*/ |
|
758 |
|
|
759 |
|
19
|
760 |
const resolvers_getDownloadableBlocks = filterValue => async _ref => { |
|
761 |
let { |
|
762 |
dispatch |
|
763 |
} = _ref; |
16
|
764 |
|
19
|
765 |
if (!filterValue) { |
|
766 |
return; |
18
|
767 |
} |
16
|
768 |
|
19
|
769 |
try { |
|
770 |
dispatch(fetchDownloadableBlocks(filterValue)); |
|
771 |
const results = await external_wp_apiFetch_default()({ |
|
772 |
path: `wp/v2/block-directory/search?term=${filterValue}` |
|
773 |
}); |
|
774 |
const blocks = results.map(result => (0,external_lodash_namespaceObject.mapKeys)(result, (value, key) => (0,external_lodash_namespaceObject.camelCase)(key))); |
|
775 |
dispatch(receiveDownloadableBlocks(blocks, filterValue)); |
|
776 |
} catch {} |
|
777 |
}; |
16
|
778 |
|
19
|
779 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/store/index.js |
16
|
780 |
/** |
|
781 |
* WordPress dependencies |
|
782 |
*/ |
|
783 |
|
|
784 |
/** |
|
785 |
* Internal dependencies |
|
786 |
*/ |
|
787 |
|
|
788 |
|
|
789 |
|
|
790 |
|
|
791 |
|
|
792 |
/** |
|
793 |
* Module Constants |
|
794 |
*/ |
|
795 |
|
18
|
796 |
const STORE_NAME = 'core/block-directory'; |
16
|
797 |
/** |
|
798 |
* Block editor data store configuration. |
|
799 |
* |
18
|
800 |
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore |
16
|
801 |
* |
|
802 |
* @type {Object} |
|
803 |
*/ |
|
804 |
|
18
|
805 |
const storeConfig = { |
16
|
806 |
reducer: reducer, |
|
807 |
selectors: selectors_namespaceObject, |
|
808 |
actions: actions_namespaceObject, |
19
|
809 |
resolvers: resolvers_namespaceObject |
16
|
810 |
}; |
18
|
811 |
/** |
|
812 |
* Store definition for the block directory namespace. |
|
813 |
* |
|
814 |
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore |
|
815 |
* |
|
816 |
* @type {Object} |
|
817 |
*/ |
16
|
818 |
|
19
|
819 |
const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, storeConfig); |
|
820 |
(0,external_wp_data_namespaceObject.register)(store); |
16
|
821 |
|
19
|
822 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/auto-block-uninstaller/index.js |
16
|
823 |
/** |
|
824 |
* WordPress dependencies |
|
825 |
*/ |
|
826 |
|
|
827 |
|
|
828 |
|
18
|
829 |
|
|
830 |
/** |
|
831 |
* Internal dependencies |
|
832 |
*/ |
|
833 |
|
16
|
834 |
|
18
|
835 |
function AutoBlockUninstaller() { |
|
836 |
const { |
|
837 |
uninstallBlockType |
19
|
838 |
} = (0,external_wp_data_namespaceObject.useDispatch)(store); |
|
839 |
const shouldRemoveBlockTypes = (0,external_wp_data_namespaceObject.useSelect)(select => { |
18
|
840 |
const { |
|
841 |
isAutosavingPost, |
|
842 |
isSavingPost |
19
|
843 |
} = select(external_wp_editor_namespaceObject.store); |
16
|
844 |
return isSavingPost() && !isAutosavingPost(); |
|
845 |
}, []); |
19
|
846 |
const unusedBlockTypes = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getUnusedBlockTypes(), []); |
|
847 |
(0,external_wp_element_namespaceObject.useEffect)(() => { |
16
|
848 |
if (shouldRemoveBlockTypes && unusedBlockTypes.length) { |
18
|
849 |
unusedBlockTypes.forEach(blockType => { |
16
|
850 |
uninstallBlockType(blockType); |
19
|
851 |
(0,external_wp_blocks_namespaceObject.unregisterBlockType)(blockType.name); |
16
|
852 |
}); |
|
853 |
} |
|
854 |
}, [shouldRemoveBlockTypes]); |
|
855 |
return null; |
|
856 |
} |
|
857 |
|
19
|
858 |
;// CONCATENATED MODULE: external ["wp","components"] |
|
859 |
var external_wp_components_namespaceObject = window["wp"]["components"]; |
|
860 |
;// CONCATENATED MODULE: external ["wp","compose"] |
|
861 |
var external_wp_compose_namespaceObject = window["wp"]["compose"]; |
|
862 |
;// CONCATENATED MODULE: external ["wp","coreData"] |
|
863 |
var external_wp_coreData_namespaceObject = window["wp"]["coreData"]; |
|
864 |
;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js |
|
865 |
function _extends() { |
|
866 |
_extends = Object.assign ? Object.assign.bind() : function (target) { |
|
867 |
for (var i = 1; i < arguments.length; i++) { |
|
868 |
var source = arguments[i]; |
16
|
869 |
|
19
|
870 |
for (var key in source) { |
|
871 |
if (Object.prototype.hasOwnProperty.call(source, key)) { |
|
872 |
target[key] = source[key]; |
|
873 |
} |
|
874 |
} |
|
875 |
} |
16
|
876 |
|
19
|
877 |
return target; |
|
878 |
}; |
|
879 |
return _extends.apply(this, arguments); |
|
880 |
} |
|
881 |
;// CONCATENATED MODULE: external ["wp","htmlEntities"] |
|
882 |
var external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"]; |
|
883 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/icon/index.js |
|
884 |
/** |
|
885 |
* WordPress dependencies |
|
886 |
*/ |
16
|
887 |
|
19
|
888 |
/** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */ |
16
|
889 |
|
19
|
890 |
/** |
|
891 |
* Return an SVG icon. |
|
892 |
* |
|
893 |
* @param {IconProps} props icon is the SVG component to render |
|
894 |
* size is a number specifiying the icon size in pixels |
|
895 |
* Other props will be passed to wrapped SVG component |
|
896 |
* |
|
897 |
* @return {JSX.Element} Icon component |
|
898 |
*/ |
16
|
899 |
|
19
|
900 |
function Icon(_ref) { |
|
901 |
let { |
|
902 |
icon, |
|
903 |
size = 24, |
|
904 |
...props |
|
905 |
} = _ref; |
|
906 |
return (0,external_wp_element_namespaceObject.cloneElement)(icon, { |
|
907 |
width: size, |
|
908 |
height: size, |
|
909 |
...props |
|
910 |
}); |
|
911 |
} |
16
|
912 |
|
19
|
913 |
/* harmony default export */ var icon = (Icon); |
16
|
914 |
|
19
|
915 |
;// CONCATENATED MODULE: external ["wp","primitives"] |
|
916 |
var external_wp_primitives_namespaceObject = window["wp"]["primitives"]; |
|
917 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/star-filled.js |
16
|
918 |
|
|
919 |
|
|
920 |
/** |
|
921 |
* WordPress dependencies |
|
922 |
*/ |
|
923 |
|
19
|
924 |
const starFilled = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
16
|
925 |
xmlns: "http://www.w3.org/2000/svg", |
|
926 |
viewBox: "0 0 24 24" |
19
|
927 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
|
928 |
d: "M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z" |
|
929 |
})); |
|
930 |
/* harmony default export */ var star_filled = (starFilled); |
|
931 |
|
|
932 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/star-half.js |
|
933 |
|
|
934 |
|
|
935 |
/** |
|
936 |
* WordPress dependencies |
|
937 |
*/ |
|
938 |
|
|
939 |
const starHalf = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
|
940 |
xmlns: "http://www.w3.org/2000/svg", |
|
941 |
viewBox: "0 0 24 24" |
|
942 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
16
|
943 |
d: "M9.518 8.783a.25.25 0 00.188-.137l2.069-4.192a.25.25 0 01.448 0l2.07 4.192a.25.25 0 00.187.137l4.626.672a.25.25 0 01.139.427l-3.347 3.262a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.363.264l-4.137-2.176a.25.25 0 00-.233 0l-4.138 2.175a.25.25 0 01-.362-.263l.79-4.607a.25.25 0 00-.072-.222L4.753 9.882a.25.25 0 01.14-.427l4.625-.672zM12 14.533c.28 0 .559.067.814.2l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39v7.143z" |
|
944 |
})); |
|
945 |
/* harmony default export */ var star_half = (starHalf); |
|
946 |
|
19
|
947 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/star-empty.js |
|
948 |
|
|
949 |
|
|
950 |
/** |
|
951 |
* WordPress dependencies |
|
952 |
*/ |
16
|
953 |
|
19
|
954 |
const starEmpty = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
|
955 |
xmlns: "http://www.w3.org/2000/svg", |
|
956 |
viewBox: "0 0 24 24" |
|
957 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
|
958 |
fillRule: "evenodd", |
|
959 |
d: "M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z", |
|
960 |
clipRule: "evenodd" |
|
961 |
})); |
|
962 |
/* harmony default export */ var star_empty = (starEmpty); |
|
963 |
|
|
964 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/block-ratings/stars.js |
16
|
965 |
|
|
966 |
|
|
967 |
/** |
|
968 |
* External dependencies |
|
969 |
*/ |
|
970 |
|
|
971 |
/** |
|
972 |
* WordPress dependencies |
|
973 |
*/ |
|
974 |
|
|
975 |
|
|
976 |
|
|
977 |
|
19
|
978 |
function Stars(_ref) { |
|
979 |
let { |
|
980 |
rating |
|
981 |
} = _ref; |
18
|
982 |
const stars = Math.round(rating / 0.5) * 0.5; |
|
983 |
const fullStarCount = Math.floor(rating); |
|
984 |
const halfStarCount = Math.ceil(rating - fullStarCount); |
|
985 |
const emptyStarCount = 5 - (fullStarCount + halfStarCount); |
19
|
986 |
return (0,external_wp_element_namespaceObject.createElement)("span", { |
|
987 |
"aria-label": (0,external_wp_i18n_namespaceObject.sprintf)( |
16
|
988 |
/* translators: %s: number of stars. */ |
19
|
989 |
(0,external_wp_i18n_namespaceObject.__)('%s out of 5 stars'), stars) |
|
990 |
}, (0,external_lodash_namespaceObject.times)(fullStarCount, i => (0,external_wp_element_namespaceObject.createElement)(icon, { |
18
|
991 |
key: `full_stars_${i}`, |
|
992 |
className: "block-directory-block-ratings__star-full", |
19
|
993 |
icon: star_filled, |
18
|
994 |
size: 16 |
19
|
995 |
})), (0,external_lodash_namespaceObject.times)(halfStarCount, i => (0,external_wp_element_namespaceObject.createElement)(icon, { |
18
|
996 |
key: `half_stars_${i}`, |
|
997 |
className: "block-directory-block-ratings__star-half-full", |
|
998 |
icon: star_half, |
|
999 |
size: 16 |
19
|
1000 |
})), (0,external_lodash_namespaceObject.times)(emptyStarCount, i => (0,external_wp_element_namespaceObject.createElement)(icon, { |
18
|
1001 |
key: `empty_stars_${i}`, |
|
1002 |
className: "block-directory-block-ratings__star-empty", |
19
|
1003 |
icon: star_empty, |
18
|
1004 |
size: 16 |
|
1005 |
}))); |
16
|
1006 |
} |
|
1007 |
|
19
|
1008 |
/* harmony default export */ var stars = (Stars); |
16
|
1009 |
|
19
|
1010 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/block-ratings/index.js |
16
|
1011 |
|
|
1012 |
|
|
1013 |
/** |
|
1014 |
* Internal dependencies |
|
1015 |
*/ |
|
1016 |
|
19
|
1017 |
const BlockRatings = _ref => { |
|
1018 |
let { |
|
1019 |
rating |
|
1020 |
} = _ref; |
|
1021 |
return (0,external_wp_element_namespaceObject.createElement)("span", { |
|
1022 |
className: "block-directory-block-ratings" |
|
1023 |
}, (0,external_wp_element_namespaceObject.createElement)(stars, { |
|
1024 |
rating: rating |
|
1025 |
})); |
|
1026 |
}; |
18
|
1027 |
/* harmony default export */ var block_ratings = (BlockRatings); |
16
|
1028 |
|
19
|
1029 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/downloadable-block-icon/index.js |
16
|
1030 |
|
|
1031 |
|
|
1032 |
/** |
|
1033 |
* WordPress dependencies |
|
1034 |
*/ |
|
1035 |
|
|
1036 |
|
19
|
1037 |
function DownloadableBlockIcon(_ref) { |
|
1038 |
let { |
|
1039 |
icon |
|
1040 |
} = _ref; |
18
|
1041 |
const className = 'block-directory-downloadable-block-icon'; |
19
|
1042 |
return icon.match(/\.(jpeg|jpg|gif|png|svg)(?:\?.*)?$/) !== null ? (0,external_wp_element_namespaceObject.createElement)("img", { |
18
|
1043 |
className: className, |
16
|
1044 |
src: icon, |
18
|
1045 |
alt: "" |
19
|
1046 |
}) : (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockIcon, { |
18
|
1047 |
className: className, |
16
|
1048 |
icon: icon, |
|
1049 |
showColors: true |
18
|
1050 |
}); |
16
|
1051 |
} |
|
1052 |
|
|
1053 |
/* harmony default export */ var downloadable_block_icon = (DownloadableBlockIcon); |
|
1054 |
|
19
|
1055 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/downloadable-block-notice/index.js |
16
|
1056 |
|
|
1057 |
|
|
1058 |
/** |
|
1059 |
* WordPress dependencies |
|
1060 |
*/ |
|
1061 |
|
|
1062 |
|
|
1063 |
/** |
|
1064 |
* Internal dependencies |
|
1065 |
*/ |
|
1066 |
|
|
1067 |
|
19
|
1068 |
const DownloadableBlockNotice = _ref => { |
|
1069 |
let { |
|
1070 |
block |
|
1071 |
} = _ref; |
|
1072 |
const errorNotice = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getErrorNoticeForBlock(block.id), [block]); |
16
|
1073 |
|
18
|
1074 |
if (!errorNotice) { |
|
1075 |
return null; |
|
1076 |
} |
16
|
1077 |
|
19
|
1078 |
return (0,external_wp_element_namespaceObject.createElement)("div", { |
18
|
1079 |
className: "block-directory-downloadable-block-notice" |
19
|
1080 |
}, (0,external_wp_element_namespaceObject.createElement)("div", { |
18
|
1081 |
className: "block-directory-downloadable-block-notice__content" |
19
|
1082 |
}, errorNotice.message, errorNotice.isFatal ? ' ' + (0,external_wp_i18n_namespaceObject.__)('Try reloading the page.') : null)); |
18
|
1083 |
}; |
|
1084 |
/* harmony default export */ var downloadable_block_notice = (DownloadableBlockNotice); |
16
|
1085 |
|
19
|
1086 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/downloadable-block-list-item/index.js |
16
|
1087 |
|
|
1088 |
|
|
1089 |
|
|
1090 |
/** |
|
1091 |
* WordPress dependencies |
|
1092 |
*/ |
|
1093 |
|
|
1094 |
|
|
1095 |
|
|
1096 |
|
|
1097 |
|
|
1098 |
|
|
1099 |
/** |
|
1100 |
* Internal dependencies |
|
1101 |
*/ |
|
1102 |
|
|
1103 |
|
|
1104 |
|
|
1105 |
|
18
|
1106 |
// Return the appropriate block item label, given the block data and status. |
16
|
1107 |
|
19
|
1108 |
function getDownloadableBlockLabel(_ref, _ref2) { |
|
1109 |
let { |
|
1110 |
title, |
|
1111 |
rating, |
|
1112 |
ratingCount |
|
1113 |
} = _ref; |
|
1114 |
let { |
|
1115 |
hasNotice, |
|
1116 |
isInstalled, |
|
1117 |
isInstalling |
|
1118 |
} = _ref2; |
18
|
1119 |
const stars = Math.round(rating / 0.5) * 0.5; |
|
1120 |
|
|
1121 |
if (!isInstalled && hasNotice) { |
|
1122 |
/* translators: %1$s: block title */ |
19
|
1123 |
return (0,external_wp_i18n_namespaceObject.sprintf)('Retry installing %s.', (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title)); |
18
|
1124 |
} |
|
1125 |
|
|
1126 |
if (isInstalled) { |
|
1127 |
/* translators: %1$s: block title */ |
19
|
1128 |
return (0,external_wp_i18n_namespaceObject.sprintf)('Add %s.', (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title)); |
18
|
1129 |
} |
|
1130 |
|
|
1131 |
if (isInstalling) { |
|
1132 |
/* translators: %1$s: block title */ |
19
|
1133 |
return (0,external_wp_i18n_namespaceObject.sprintf)('Installing %s.', (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title)); |
18
|
1134 |
} // No ratings yet, just use the title. |
|
1135 |
|
|
1136 |
|
|
1137 |
if (ratingCount < 1) { |
|
1138 |
/* translators: %1$s: block title */ |
19
|
1139 |
return (0,external_wp_i18n_namespaceObject.sprintf)('Install %s.', (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title)); |
18
|
1140 |
} |
16
|
1141 |
|
19
|
1142 |
return (0,external_wp_i18n_namespaceObject.sprintf)( |
18
|
1143 |
/* translators: %1$s: block title, %2$s: average rating, %3$s: total ratings count. */ |
19
|
1144 |
(0,external_wp_i18n_namespaceObject._n)('Install %1$s. %2$s stars with %3$s review.', 'Install %1$s. %2$s stars with %3$s reviews.', ratingCount), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title), stars, ratingCount); |
18
|
1145 |
} |
16
|
1146 |
|
19
|
1147 |
function DownloadableBlockListItem(_ref3) { |
|
1148 |
let { |
|
1149 |
composite, |
|
1150 |
item, |
|
1151 |
onClick |
|
1152 |
} = _ref3; |
18
|
1153 |
const { |
|
1154 |
author, |
|
1155 |
description, |
|
1156 |
icon, |
|
1157 |
rating, |
|
1158 |
title |
|
1159 |
} = item; // getBlockType returns a block object if this block exists, or null if not. |
|
1160 |
|
19
|
1161 |
const isInstalled = !!(0,external_wp_blocks_namespaceObject.getBlockType)(item.name); |
18
|
1162 |
const { |
|
1163 |
hasNotice, |
|
1164 |
isInstalling, |
|
1165 |
isInstallable |
19
|
1166 |
} = (0,external_wp_data_namespaceObject.useSelect)(select => { |
18
|
1167 |
const { |
|
1168 |
getErrorNoticeForBlock, |
|
1169 |
isInstalling: isBlockInstalling |
|
1170 |
} = select(store); |
|
1171 |
const notice = getErrorNoticeForBlock(item.id); |
|
1172 |
const hasFatal = notice && notice.isFatal; |
16
|
1173 |
return { |
18
|
1174 |
hasNotice: !!notice, |
|
1175 |
isInstalling: isBlockInstalling(item.id), |
16
|
1176 |
isInstallable: !hasFatal |
|
1177 |
}; |
18
|
1178 |
}, [item]); |
|
1179 |
let statusText = ''; |
|
1180 |
|
|
1181 |
if (isInstalled) { |
19
|
1182 |
statusText = (0,external_wp_i18n_namespaceObject.__)('Installed!'); |
18
|
1183 |
} else if (isInstalling) { |
19
|
1184 |
statusText = (0,external_wp_i18n_namespaceObject.__)('Installing…'); |
18
|
1185 |
} |
16
|
1186 |
|
19
|
1187 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableCompositeItem, _extends({ |
|
1188 |
__experimentalIsFocusable: true, |
18
|
1189 |
role: "option", |
19
|
1190 |
as: external_wp_components_namespaceObject.Button |
18
|
1191 |
}, composite, { |
|
1192 |
className: "block-directory-downloadable-block-list-item", |
|
1193 |
onClick: event => { |
|
1194 |
event.preventDefault(); |
|
1195 |
onClick(); |
|
1196 |
}, |
|
1197 |
isBusy: isInstalling, |
|
1198 |
disabled: isInstalling || !isInstallable, |
|
1199 |
label: getDownloadableBlockLabel(item, { |
|
1200 |
hasNotice, |
|
1201 |
isInstalled, |
|
1202 |
isInstalling |
|
1203 |
}), |
|
1204 |
showTooltip: true, |
|
1205 |
tooltipPosition: "top center" |
19
|
1206 |
}), (0,external_wp_element_namespaceObject.createElement)("div", { |
18
|
1207 |
className: "block-directory-downloadable-block-list-item__icon" |
19
|
1208 |
}, (0,external_wp_element_namespaceObject.createElement)(downloadable_block_icon, { |
16
|
1209 |
icon: icon, |
18
|
1210 |
title: title |
19
|
1211 |
}), isInstalling ? (0,external_wp_element_namespaceObject.createElement)("span", { |
18
|
1212 |
className: "block-directory-downloadable-block-list-item__spinner" |
19
|
1213 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null)) : (0,external_wp_element_namespaceObject.createElement)(block_ratings, { |
18
|
1214 |
rating: rating |
19
|
1215 |
})), (0,external_wp_element_namespaceObject.createElement)("span", { |
18
|
1216 |
className: "block-directory-downloadable-block-list-item__details" |
19
|
1217 |
}, (0,external_wp_element_namespaceObject.createElement)("span", { |
18
|
1218 |
className: "block-directory-downloadable-block-list-item__title" |
19
|
1219 |
}, (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( |
18
|
1220 |
/* translators: %1$s: block title, %2$s: author name. */ |
19
|
1221 |
(0,external_wp_i18n_namespaceObject.__)('%1$s <span>by %2$s</span>'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title), author), { |
|
1222 |
span: (0,external_wp_element_namespaceObject.createElement)("span", { |
18
|
1223 |
className: "block-directory-downloadable-block-list-item__author" |
|
1224 |
}) |
19
|
1225 |
})), hasNotice ? (0,external_wp_element_namespaceObject.createElement)(downloadable_block_notice, { |
16
|
1226 |
block: item |
19
|
1227 |
}) : (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("span", { |
18
|
1228 |
className: "block-directory-downloadable-block-list-item__desc" |
19
|
1229 |
}, !!statusText ? statusText : (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(description)), isInstallable && !(isInstalled || isInstalling) && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, null, (0,external_wp_i18n_namespaceObject.__)('Install block'))))); |
16
|
1230 |
} |
|
1231 |
|
18
|
1232 |
/* harmony default export */ var downloadable_block_list_item = (DownloadableBlockListItem); |
|
1233 |
|
19
|
1234 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/downloadable-blocks-list/index.js |
16
|
1235 |
|
|
1236 |
|
18
|
1237 |
|
16
|
1238 |
/** |
|
1239 |
* External dependencies |
|
1240 |
*/ |
|
1241 |
|
|
1242 |
/** |
|
1243 |
* WordPress dependencies |
|
1244 |
*/ |
|
1245 |
|
|
1246 |
|
|
1247 |
|
|
1248 |
|
|
1249 |
|
|
1250 |
/** |
|
1251 |
* Internal dependencies |
|
1252 |
*/ |
|
1253 |
|
|
1254 |
|
|
1255 |
|
|
1256 |
|
19
|
1257 |
function DownloadableBlocksList(_ref) { |
|
1258 |
let { |
|
1259 |
items, |
|
1260 |
onHover = external_lodash_namespaceObject.noop, |
|
1261 |
onSelect |
|
1262 |
} = _ref; |
|
1263 |
const composite = (0,external_wp_components_namespaceObject.__unstableUseCompositeState)(); |
18
|
1264 |
const { |
|
1265 |
installBlockType |
19
|
1266 |
} = (0,external_wp_data_namespaceObject.useDispatch)(store); |
18
|
1267 |
|
|
1268 |
if (!items.length) { |
|
1269 |
return null; |
16
|
1270 |
} |
|
1271 |
|
19
|
1272 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__unstableComposite, _extends({}, composite, { |
18
|
1273 |
role: "listbox", |
|
1274 |
className: "block-directory-downloadable-blocks-list", |
19
|
1275 |
"aria-label": (0,external_wp_i18n_namespaceObject.__)('Blocks available for install') |
18
|
1276 |
}), items.map(item => { |
19
|
1277 |
return (0,external_wp_element_namespaceObject.createElement)(downloadable_block_list_item, { |
18
|
1278 |
key: item.id, |
|
1279 |
composite: composite, |
|
1280 |
onClick: () => { |
|
1281 |
// Check if the block is registered (`getBlockType` |
|
1282 |
// will return an object). If so, insert the block. |
|
1283 |
// This prevents installing existing plugins. |
19
|
1284 |
if ((0,external_wp_blocks_namespaceObject.getBlockType)(item.name)) { |
18
|
1285 |
onSelect(item); |
|
1286 |
} else { |
|
1287 |
installBlockType(item).then(success => { |
|
1288 |
if (success) { |
|
1289 |
onSelect(item); |
|
1290 |
} |
|
1291 |
}); |
|
1292 |
} |
|
1293 |
|
|
1294 |
onHover(null); |
|
1295 |
}, |
|
1296 |
onHover: onHover, |
|
1297 |
item: item |
|
1298 |
}); |
|
1299 |
})); |
|
1300 |
} |
|
1301 |
|
|
1302 |
/* harmony default export */ var downloadable_blocks_list = (DownloadableBlocksList); |
|
1303 |
|
19
|
1304 |
;// CONCATENATED MODULE: external ["wp","a11y"] |
|
1305 |
var external_wp_a11y_namespaceObject = window["wp"]["a11y"]; |
|
1306 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/downloadable-blocks-panel/inserter-panel.js |
18
|
1307 |
|
|
1308 |
|
|
1309 |
/** |
|
1310 |
* WordPress dependencies |
|
1311 |
*/ |
|
1312 |
|
|
1313 |
|
|
1314 |
|
|
1315 |
|
19
|
1316 |
function DownloadableBlocksInserterPanel(_ref) { |
|
1317 |
let { |
|
1318 |
children, |
|
1319 |
downloadableItems, |
|
1320 |
hasLocalBlocks |
|
1321 |
} = _ref; |
18
|
1322 |
const count = downloadableItems.length; |
19
|
1323 |
(0,external_wp_element_namespaceObject.useEffect)(() => { |
|
1324 |
(0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.sprintf)( |
18
|
1325 |
/* translators: %d: number of available blocks. */ |
19
|
1326 |
(0,external_wp_i18n_namespaceObject._n)('%d additional block is available to install.', '%d additional blocks are available to install.', count), count)); |
18
|
1327 |
}, [count]); |
19
|
1328 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, !hasLocalBlocks && (0,external_wp_element_namespaceObject.createElement)("p", { |
18
|
1329 |
className: "block-directory-downloadable-blocks-panel__no-local" |
19
|
1330 |
}, (0,external_wp_i18n_namespaceObject.__)('No results available from your installed blocks.')), (0,external_wp_element_namespaceObject.createElement)("div", { |
18
|
1331 |
className: "block-editor-inserter__quick-inserter-separator" |
19
|
1332 |
}), (0,external_wp_element_namespaceObject.createElement)("div", { |
18
|
1333 |
className: "block-directory-downloadable-blocks-panel" |
19
|
1334 |
}, (0,external_wp_element_namespaceObject.createElement)("div", { |
18
|
1335 |
className: "block-directory-downloadable-blocks-panel__header" |
19
|
1336 |
}, (0,external_wp_element_namespaceObject.createElement)("h2", { |
18
|
1337 |
className: "block-directory-downloadable-blocks-panel__title" |
19
|
1338 |
}, (0,external_wp_i18n_namespaceObject.__)('Available to install')), (0,external_wp_element_namespaceObject.createElement)("p", { |
18
|
1339 |
className: "block-directory-downloadable-blocks-panel__description" |
19
|
1340 |
}, (0,external_wp_i18n_namespaceObject.__)('Select a block to install and add it to your post.'))), children)); |
18
|
1341 |
} |
|
1342 |
|
|
1343 |
/* harmony default export */ var inserter_panel = (DownloadableBlocksInserterPanel); |
|
1344 |
|
19
|
1345 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/block-default.js |
|
1346 |
|
|
1347 |
|
|
1348 |
/** |
|
1349 |
* WordPress dependencies |
|
1350 |
*/ |
18
|
1351 |
|
19
|
1352 |
const blockDefault = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, { |
|
1353 |
xmlns: "http://www.w3.org/2000/svg", |
|
1354 |
viewBox: "0 0 24 24" |
|
1355 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, { |
|
1356 |
d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z" |
|
1357 |
})); |
|
1358 |
/* harmony default export */ var block_default = (blockDefault); |
|
1359 |
|
|
1360 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/downloadable-blocks-panel/no-results.js |
18
|
1361 |
|
|
1362 |
|
|
1363 |
/** |
|
1364 |
* WordPress dependencies |
|
1365 |
*/ |
|
1366 |
|
|
1367 |
|
|
1368 |
|
|
1369 |
function DownloadableBlocksNoResults() { |
19
|
1370 |
return (0,external_wp_element_namespaceObject.createElement)("div", { |
18
|
1371 |
className: "block-editor-inserter__no-results" |
19
|
1372 |
}, (0,external_wp_element_namespaceObject.createElement)(icon, { |
18
|
1373 |
className: "block-editor-inserter__no-results-icon", |
19
|
1374 |
icon: block_default |
|
1375 |
}), (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('No results found.'))); |
18
|
1376 |
} |
|
1377 |
|
|
1378 |
/* harmony default export */ var no_results = (DownloadableBlocksNoResults); |
|
1379 |
|
19
|
1380 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/downloadable-blocks-panel/index.js |
18
|
1381 |
|
|
1382 |
|
|
1383 |
/** |
|
1384 |
* WordPress dependencies |
|
1385 |
*/ |
|
1386 |
|
|
1387 |
|
|
1388 |
|
|
1389 |
|
|
1390 |
|
|
1391 |
|
|
1392 |
/** |
|
1393 |
* Internal dependencies |
|
1394 |
*/ |
|
1395 |
|
|
1396 |
|
|
1397 |
|
|
1398 |
|
|
1399 |
|
|
1400 |
|
19
|
1401 |
function DownloadableBlocksPanel(_ref) { |
|
1402 |
let { |
|
1403 |
downloadableItems, |
|
1404 |
onSelect, |
|
1405 |
onHover, |
|
1406 |
hasLocalBlocks, |
|
1407 |
hasPermission, |
|
1408 |
isLoading, |
|
1409 |
isTyping |
|
1410 |
} = _ref; |
|
1411 |
|
18
|
1412 |
if (typeof hasPermission === 'undefined' || isLoading || isTyping) { |
19
|
1413 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, hasPermission && !hasLocalBlocks && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("p", { |
18
|
1414 |
className: "block-directory-downloadable-blocks-panel__no-local" |
19
|
1415 |
}, (0,external_wp_i18n_namespaceObject.__)('No results available from your installed blocks.')), (0,external_wp_element_namespaceObject.createElement)("div", { |
18
|
1416 |
className: "block-editor-inserter__quick-inserter-separator" |
19
|
1417 |
})), (0,external_wp_element_namespaceObject.createElement)("div", { |
18
|
1418 |
className: "block-directory-downloadable-blocks-panel has-blocks-loading" |
19
|
1419 |
}, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null))); |
16
|
1420 |
} |
|
1421 |
|
18
|
1422 |
if (false === hasPermission) { |
|
1423 |
if (!hasLocalBlocks) { |
19
|
1424 |
return (0,external_wp_element_namespaceObject.createElement)(no_results, null); |
18
|
1425 |
} |
|
1426 |
|
|
1427 |
return null; |
16
|
1428 |
} |
|
1429 |
|
19
|
1430 |
return !!downloadableItems.length ? (0,external_wp_element_namespaceObject.createElement)(inserter_panel, { |
18
|
1431 |
downloadableItems: downloadableItems, |
|
1432 |
hasLocalBlocks: hasLocalBlocks |
19
|
1433 |
}, (0,external_wp_element_namespaceObject.createElement)(downloadable_blocks_list, { |
16
|
1434 |
items: downloadableItems, |
|
1435 |
onSelect: onSelect, |
|
1436 |
onHover: onHover |
19
|
1437 |
})) : !hasLocalBlocks && (0,external_wp_element_namespaceObject.createElement)(no_results, null); |
16
|
1438 |
} |
|
1439 |
|
19
|
1440 |
/* harmony default export */ var downloadable_blocks_panel = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, _ref2) => { |
|
1441 |
let { |
|
1442 |
filterValue, |
|
1443 |
rootClientId = null |
|
1444 |
} = _ref2; |
18
|
1445 |
const { |
|
1446 |
getDownloadableBlocks, |
|
1447 |
isRequestingDownloadableBlocks |
|
1448 |
} = select(store); |
|
1449 |
const { |
|
1450 |
canInsertBlockType |
19
|
1451 |
} = select(external_wp_blockEditor_namespaceObject.store); |
|
1452 |
const hasPermission = select(external_wp_coreData_namespaceObject.store).canUser('read', 'block-directory/search'); |
16
|
1453 |
|
18
|
1454 |
function getInstallableBlocks(term) { |
|
1455 |
return getDownloadableBlocks(term).filter(block => canInsertBlockType(block, rootClientId, true)); |
|
1456 |
} |
|
1457 |
|
|
1458 |
const downloadableItems = hasPermission ? getInstallableBlocks(filterValue) : []; |
|
1459 |
const isLoading = isRequestingDownloadableBlocks(filterValue); |
16
|
1460 |
return { |
18
|
1461 |
downloadableItems, |
|
1462 |
hasPermission, |
|
1463 |
isLoading |
16
|
1464 |
}; |
|
1465 |
})])(DownloadableBlocksPanel)); |
|
1466 |
|
19
|
1467 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.js |
16
|
1468 |
|
|
1469 |
|
|
1470 |
/** |
|
1471 |
* External dependencies |
|
1472 |
*/ |
|
1473 |
|
|
1474 |
/** |
|
1475 |
* WordPress dependencies |
|
1476 |
*/ |
|
1477 |
|
|
1478 |
|
|
1479 |
|
|
1480 |
/** |
|
1481 |
* Internal dependencies |
|
1482 |
*/ |
|
1483 |
|
|
1484 |
|
|
1485 |
|
|
1486 |
function InserterMenuDownloadableBlocksPanel() { |
19
|
1487 |
const [debouncedFilterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)(''); |
|
1488 |
const debouncedSetFilterValue = (0,external_lodash_namespaceObject.debounce)(setFilterValue, 400); |
|
1489 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__unstableInserterMenuExtension, null, _ref => { |
|
1490 |
let { |
|
1491 |
onSelect, |
|
1492 |
onHover, |
|
1493 |
filterValue, |
|
1494 |
hasItems, |
|
1495 |
rootClientId |
|
1496 |
} = _ref; |
|
1497 |
|
16
|
1498 |
if (debouncedFilterValue !== filterValue) { |
|
1499 |
debouncedSetFilterValue(filterValue); |
|
1500 |
} |
|
1501 |
|
18
|
1502 |
if (!debouncedFilterValue) { |
|
1503 |
return null; |
|
1504 |
} |
|
1505 |
|
19
|
1506 |
return (0,external_wp_element_namespaceObject.createElement)(downloadable_blocks_panel, { |
16
|
1507 |
onSelect: onSelect, |
|
1508 |
onHover: onHover, |
18
|
1509 |
rootClientId: rootClientId, |
16
|
1510 |
filterValue: debouncedFilterValue, |
18
|
1511 |
hasLocalBlocks: hasItems, |
|
1512 |
isTyping: filterValue !== debouncedFilterValue |
16
|
1513 |
}); |
|
1514 |
}); |
|
1515 |
} |
|
1516 |
|
|
1517 |
/* harmony default export */ var inserter_menu_downloadable_blocks_panel = (InserterMenuDownloadableBlocksPanel); |
|
1518 |
|
19
|
1519 |
;// CONCATENATED MODULE: external ["wp","editPost"] |
|
1520 |
var external_wp_editPost_namespaceObject = window["wp"]["editPost"]; |
|
1521 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/components/compact-list/index.js |
16
|
1522 |
|
|
1523 |
|
|
1524 |
/** |
|
1525 |
* WordPress dependencies |
|
1526 |
*/ |
|
1527 |
|
|
1528 |
/** |
|
1529 |
* Internal dependencies |
|
1530 |
*/ |
|
1531 |
|
|
1532 |
|
19
|
1533 |
function CompactList(_ref) { |
|
1534 |
let { |
|
1535 |
items |
|
1536 |
} = _ref; |
|
1537 |
|
16
|
1538 |
if (!items.length) { |
|
1539 |
return null; |
|
1540 |
} |
|
1541 |
|
19
|
1542 |
return (0,external_wp_element_namespaceObject.createElement)("ul", { |
16
|
1543 |
className: "block-directory-compact-list" |
19
|
1544 |
}, items.map(_ref2 => { |
|
1545 |
let { |
|
1546 |
icon, |
|
1547 |
id, |
|
1548 |
title, |
|
1549 |
author |
|
1550 |
} = _ref2; |
|
1551 |
return (0,external_wp_element_namespaceObject.createElement)("li", { |
|
1552 |
key: id, |
|
1553 |
className: "block-directory-compact-list__item" |
|
1554 |
}, (0,external_wp_element_namespaceObject.createElement)(downloadable_block_icon, { |
|
1555 |
icon: icon, |
|
1556 |
title: title |
|
1557 |
}), (0,external_wp_element_namespaceObject.createElement)("div", { |
|
1558 |
className: "block-directory-compact-list__item-details" |
|
1559 |
}, (0,external_wp_element_namespaceObject.createElement)("div", { |
|
1560 |
className: "block-directory-compact-list__item-title" |
|
1561 |
}, title), (0,external_wp_element_namespaceObject.createElement)("div", { |
|
1562 |
className: "block-directory-compact-list__item-author" |
|
1563 |
}, (0,external_wp_i18n_namespaceObject.sprintf)( |
|
1564 |
/* translators: %s: Name of the block author. */ |
|
1565 |
(0,external_wp_i18n_namespaceObject.__)('By %s'), author)))); |
|
1566 |
})); |
16
|
1567 |
} |
|
1568 |
|
19
|
1569 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/plugins/installed-blocks-pre-publish-panel/index.js |
16
|
1570 |
|
|
1571 |
|
|
1572 |
/** |
|
1573 |
* WordPress dependencies |
|
1574 |
*/ |
|
1575 |
|
|
1576 |
|
|
1577 |
|
18
|
1578 |
|
|
1579 |
/** |
|
1580 |
* Internal dependencies |
|
1581 |
*/ |
|
1582 |
|
|
1583 |
|
|
1584 |
|
|
1585 |
function InstalledBlocksPrePublishPanel() { |
19
|
1586 |
const newBlockTypes = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getNewBlockTypes(), []); |
18
|
1587 |
|
|
1588 |
if (!newBlockTypes.length) { |
|
1589 |
return null; |
|
1590 |
} |
|
1591 |
|
19
|
1592 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_editPost_namespaceObject.PluginPrePublishPanel, { |
|
1593 |
icon: block_default, |
|
1594 |
title: (0,external_wp_i18n_namespaceObject.sprintf)( // translators: %d: number of blocks (number). |
|
1595 |
(0,external_wp_i18n_namespaceObject._n)('Added: %d block', 'Added: %d blocks', newBlockTypes.length), newBlockTypes.length), |
18
|
1596 |
initialOpen: true |
19
|
1597 |
}, (0,external_wp_element_namespaceObject.createElement)("p", { |
18
|
1598 |
className: "installed-blocks-pre-publish-panel__copy" |
19
|
1599 |
}, (0,external_wp_i18n_namespaceObject._n)('The following block has been added to your site.', 'The following blocks have been added to your site.', newBlockTypes.length)), (0,external_wp_element_namespaceObject.createElement)(CompactList, { |
18
|
1600 |
items: newBlockTypes |
|
1601 |
})); |
|
1602 |
} |
|
1603 |
|
19
|
1604 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/plugins/get-install-missing/install-button.js |
18
|
1605 |
|
|
1606 |
|
|
1607 |
/** |
|
1608 |
* WordPress dependencies |
|
1609 |
*/ |
|
1610 |
|
|
1611 |
|
|
1612 |
|
|
1613 |
|
|
1614 |
|
16
|
1615 |
/** |
|
1616 |
* Internal dependencies |
|
1617 |
*/ |
|
1618 |
|
|
1619 |
|
19
|
1620 |
function InstallButton(_ref) { |
|
1621 |
let { |
|
1622 |
attributes, |
|
1623 |
block, |
|
1624 |
clientId |
|
1625 |
} = _ref; |
|
1626 |
const isInstallingBlock = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isInstalling(block.id), [block.id]); |
18
|
1627 |
const { |
|
1628 |
installBlockType |
19
|
1629 |
} = (0,external_wp_data_namespaceObject.useDispatch)(store); |
18
|
1630 |
const { |
|
1631 |
replaceBlock |
19
|
1632 |
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); |
|
1633 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { |
18
|
1634 |
onClick: () => installBlockType(block).then(success => { |
|
1635 |
if (success) { |
19
|
1636 |
const blockType = (0,external_wp_blocks_namespaceObject.getBlockType)(block.name); |
|
1637 |
const [originalBlock] = (0,external_wp_blocks_namespaceObject.parse)(attributes.originalContent); |
18
|
1638 |
|
19
|
1639 |
if (originalBlock && blockType) { |
|
1640 |
replaceBlock(clientId, (0,external_wp_blocks_namespaceObject.createBlock)(blockType.name, originalBlock.attributes, originalBlock.innerBlocks)); |
18
|
1641 |
} |
|
1642 |
} |
|
1643 |
}), |
|
1644 |
disabled: isInstallingBlock, |
|
1645 |
isBusy: isInstallingBlock, |
19
|
1646 |
variant: "primary" |
|
1647 |
}, (0,external_wp_i18n_namespaceObject.sprintf)( |
18
|
1648 |
/* translators: %s: block name */ |
19
|
1649 |
(0,external_wp_i18n_namespaceObject.__)('Install %s'), block.title)); |
18
|
1650 |
} |
|
1651 |
|
19
|
1652 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/plugins/get-install-missing/index.js |
18
|
1653 |
|
|
1654 |
|
16
|
1655 |
|
18
|
1656 |
/** |
|
1657 |
* WordPress dependencies |
|
1658 |
*/ |
|
1659 |
|
|
1660 |
|
|
1661 |
|
|
1662 |
|
|
1663 |
|
|
1664 |
|
|
1665 |
|
|
1666 |
/** |
|
1667 |
* Internal dependencies |
|
1668 |
*/ |
|
1669 |
|
|
1670 |
|
|
1671 |
|
|
1672 |
|
|
1673 |
const getInstallMissing = OriginalComponent => props => { |
|
1674 |
const { |
|
1675 |
originalName |
|
1676 |
} = props.attributes; // Disable reason: This is a valid component, but it's mistaken for a callback. |
|
1677 |
// eslint-disable-next-line react-hooks/rules-of-hooks |
|
1678 |
|
|
1679 |
const { |
|
1680 |
block, |
|
1681 |
hasPermission |
19
|
1682 |
} = (0,external_wp_data_namespaceObject.useSelect)(select => { |
18
|
1683 |
const { |
|
1684 |
getDownloadableBlocks |
|
1685 |
} = select(store); |
19
|
1686 |
const blocks = getDownloadableBlocks('block:' + originalName).filter(_ref => { |
|
1687 |
let { |
|
1688 |
name |
|
1689 |
} = _ref; |
|
1690 |
return originalName === name; |
|
1691 |
}); |
18
|
1692 |
return { |
19
|
1693 |
hasPermission: select(external_wp_coreData_namespaceObject.store).canUser('read', 'block-directory/search'), |
18
|
1694 |
block: blocks.length && blocks[0] |
|
1695 |
}; |
|
1696 |
}, [originalName]); // The user can't install blocks, or the block isn't available for download. |
|
1697 |
|
|
1698 |
if (!hasPermission || !block) { |
19
|
1699 |
return (0,external_wp_element_namespaceObject.createElement)(OriginalComponent, props); |
16
|
1700 |
} |
|
1701 |
|
19
|
1702 |
return (0,external_wp_element_namespaceObject.createElement)(ModifiedWarning, _extends({}, props, { |
18
|
1703 |
originalBlock: block |
16
|
1704 |
})); |
18
|
1705 |
}; |
|
1706 |
|
19
|
1707 |
const ModifiedWarning = _ref2 => { |
|
1708 |
let { |
|
1709 |
originalBlock, |
|
1710 |
...props |
|
1711 |
} = _ref2; |
18
|
1712 |
const { |
|
1713 |
originalName, |
|
1714 |
originalUndelimitedContent |
|
1715 |
} = props.attributes; |
|
1716 |
const { |
|
1717 |
replaceBlock |
19
|
1718 |
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store); |
18
|
1719 |
|
|
1720 |
const convertToHTML = () => { |
19
|
1721 |
replaceBlock(props.clientId, (0,external_wp_blocks_namespaceObject.createBlock)('core/html', { |
18
|
1722 |
content: originalUndelimitedContent |
|
1723 |
})); |
|
1724 |
}; |
|
1725 |
|
|
1726 |
const hasContent = !!originalUndelimitedContent; |
19
|
1727 |
const hasHTMLBlock = (0,external_wp_blocks_namespaceObject.getBlockType)('core/html'); |
|
1728 |
let messageHTML = (0,external_wp_i18n_namespaceObject.sprintf)( |
18
|
1729 |
/* translators: %s: block name */ |
19
|
1730 |
(0,external_wp_i18n_namespaceObject.__)('Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely.'), originalBlock.title || originalName); |
|
1731 |
const actions = [(0,external_wp_element_namespaceObject.createElement)(InstallButton, { |
18
|
1732 |
key: "install", |
|
1733 |
block: originalBlock, |
|
1734 |
attributes: props.attributes, |
|
1735 |
clientId: props.clientId |
|
1736 |
})]; |
|
1737 |
|
|
1738 |
if (hasContent && hasHTMLBlock) { |
19
|
1739 |
messageHTML = (0,external_wp_i18n_namespaceObject.sprintf)( |
18
|
1740 |
/* translators: %s: block name */ |
19
|
1741 |
(0,external_wp_i18n_namespaceObject.__)('Your site doesn’t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely.'), originalBlock.title || originalName); |
|
1742 |
actions.push((0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, { |
18
|
1743 |
key: "convert", |
|
1744 |
onClick: convertToHTML, |
19
|
1745 |
variant: "link" |
|
1746 |
}, (0,external_wp_i18n_namespaceObject.__)('Keep as HTML'))); |
18
|
1747 |
} |
|
1748 |
|
19
|
1749 |
return (0,external_wp_element_namespaceObject.createElement)("div", (0,external_wp_blockEditor_namespaceObject.useBlockProps)(), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.Warning, { |
18
|
1750 |
actions: actions |
19
|
1751 |
}, messageHTML), (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.RawHTML, null, originalUndelimitedContent)); |
18
|
1752 |
}; |
|
1753 |
|
|
1754 |
/* harmony default export */ var get_install_missing = (getInstallMissing); |
16
|
1755 |
|
19
|
1756 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/plugins/index.js |
16
|
1757 |
|
|
1758 |
|
|
1759 |
/** |
|
1760 |
* WordPress dependencies |
|
1761 |
*/ |
|
1762 |
|
|
1763 |
|
|
1764 |
/** |
|
1765 |
* Internal dependencies |
|
1766 |
*/ |
|
1767 |
|
|
1768 |
|
|
1769 |
|
|
1770 |
|
|
1771 |
|
19
|
1772 |
(0,external_wp_plugins_namespaceObject.registerPlugin)('block-directory', { |
18
|
1773 |
render() { |
19
|
1774 |
return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(AutoBlockUninstaller, null), (0,external_wp_element_namespaceObject.createElement)(inserter_menu_downloadable_blocks_panel, null), (0,external_wp_element_namespaceObject.createElement)(InstalledBlocksPrePublishPanel, null)); |
18
|
1775 |
} |
|
1776 |
|
|
1777 |
}); |
19
|
1778 |
(0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'block-directory/fallback', (settings, name) => { |
18
|
1779 |
if (name !== 'core/missing') { |
|
1780 |
return settings; |
|
1781 |
} |
|
1782 |
|
|
1783 |
settings.edit = get_install_missing(settings.edit); |
|
1784 |
return settings; |
|
1785 |
}); |
|
1786 |
|
19
|
1787 |
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-directory/build-module/index.js |
18
|
1788 |
/** |
|
1789 |
* Internal dependencies |
|
1790 |
*/ |
|
1791 |
|
|
1792 |
|
|
1793 |
|
19
|
1794 |
(window.wp = window.wp || {}).blockDirectory = __webpack_exports__; |
|
1795 |
/******/ })() |
|
1796 |
; |