2020-10-20 15:36:16 +02:00
this [ "wp" ] = this [ "wp" ] || { } ; this [ "wp" ] [ "reusableBlocks" ] =
/******/ ( function ( modules ) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = { } ;
/******/
/******/ // The require function
/******/ function _ _webpack _require _ _ ( moduleId ) {
/******/
/******/ // Check if module is in cache
/******/ if ( installedModules [ moduleId ] ) {
/******/ return installedModules [ moduleId ] . exports ;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules [ moduleId ] = {
/******/ i : moduleId ,
/******/ l : false ,
/******/ exports : { }
/******/ } ;
/******/
/******/ // Execute the module function
/******/ modules [ moduleId ] . call ( module . exports , module , module . exports , _ _webpack _require _ _ ) ;
/******/
/******/ // Flag the module as loaded
/******/ module . l = true ;
/******/
/******/ // Return the exports of the module
/******/ return module . exports ;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ _ _webpack _require _ _ . m = modules ;
/******/
/******/ // expose the module cache
/******/ _ _webpack _require _ _ . c = installedModules ;
/******/
/******/ // define getter function for harmony exports
/******/ _ _webpack _require _ _ . d = function ( exports , name , getter ) {
/******/ if ( ! _ _webpack _require _ _ . o ( exports , name ) ) {
/******/ Object . defineProperty ( exports , name , { enumerable : true , get : getter } ) ;
/******/ }
/******/ } ;
/******/
/******/ // define __esModule on exports
/******/ _ _webpack _require _ _ . r = function ( exports ) {
/******/ if ( typeof Symbol !== 'undefined' && Symbol . toStringTag ) {
/******/ Object . defineProperty ( exports , Symbol . toStringTag , { value : 'Module' } ) ;
/******/ }
/******/ Object . defineProperty ( exports , '__esModule' , { value : true } ) ;
/******/ } ;
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ _ _webpack _require _ _ . t = function ( value , mode ) {
/******/ if ( mode & 1 ) value = _ _webpack _require _ _ ( value ) ;
/******/ if ( mode & 8 ) return value ;
/******/ if ( ( mode & 4 ) && typeof value === 'object' && value && value . _ _esModule ) return value ;
/******/ var ns = Object . create ( null ) ;
/******/ _ _webpack _require _ _ . r ( ns ) ;
/******/ Object . defineProperty ( ns , 'default' , { enumerable : true , value : value } ) ;
/******/ if ( mode & 2 && typeof value != 'string' ) for ( var key in value ) _ _webpack _require _ _ . d ( ns , key , function ( key ) { return value [ key ] ; } . bind ( null , key ) ) ;
/******/ return ns ;
/******/ } ;
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ _ _webpack _require _ _ . n = function ( module ) {
/******/ var getter = module && module . _ _esModule ?
/******/ function getDefault ( ) { return module [ 'default' ] ; } :
/******/ function getModuleExports ( ) { return module ; } ;
/******/ _ _webpack _require _ _ . d ( getter , 'a' , getter ) ;
/******/ return getter ;
/******/ } ;
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ _ _webpack _require _ _ . o = function ( object , property ) { return Object . prototype . hasOwnProperty . call ( object , property ) ; } ;
/******/
/******/ // __webpack_public_path__
/******/ _ _webpack _require _ _ . p = "" ;
/******/
/******/
/******/ // Load entry module and return exports
2021-05-19 17:09:27 +02:00
/******/ return _ _webpack _require _ _ ( _ _webpack _require _ _ . s = 569 ) ;
2020-10-20 15:36:16 +02:00
/******/ } )
/************************************************************************/
/******/ ( {
/***/ 0 :
/***/ ( function ( module , exports ) {
2021-01-28 03:04:13 +01:00
( function ( ) { module . exports = window [ "wp" ] [ "element" ] ; } ( ) ) ;
2020-10-20 15:36:16 +02:00
/***/ } ) ,
/***/ 1 :
/***/ ( function ( module , exports ) {
2021-01-28 03:04:13 +01:00
( function ( ) { module . exports = window [ "wp" ] [ "i18n" ] ; } ( ) ) ;
2020-10-20 15:36:16 +02:00
/***/ } ) ,
2021-05-19 17:09:27 +02:00
/***/ 18 :
/***/ ( function ( module , exports ) {
2021-04-15 17:19:43 +02:00
2021-05-19 17:09:27 +02:00
( function ( ) { module . exports = window [ "wp" ] [ "coreData" ] ; } ( ) ) ;
2021-04-15 17:19:43 +02:00
2021-05-19 17:09:27 +02:00
/***/ } ) ,
2021-04-15 17:19:43 +02:00
2021-05-19 17:09:27 +02:00
/***/ 2 :
/***/ ( function ( module , exports ) {
2021-04-15 17:19:43 +02:00
2021-05-19 17:09:27 +02:00
( function ( ) { module . exports = window [ "lodash" ] ; } ( ) ) ;
2021-04-15 17:19:43 +02:00
/***/ } ) ,
2021-05-19 17:09:27 +02:00
/***/ 20 :
2020-10-20 15:36:16 +02:00
/***/ ( function ( module , exports ) {
2021-05-19 17:09:27 +02:00
( function ( ) { module . exports = window [ "wp" ] [ "url" ] ; } ( ) ) ;
2020-10-20 15:36:16 +02:00
/***/ } ) ,
2021-05-19 17:09:27 +02:00
/***/ 3 :
2021-03-01 09:25:27 +01:00
/***/ ( function ( module , exports ) {
2021-05-19 17:09:27 +02:00
( function ( ) { module . exports = window [ "wp" ] [ "primitives" ] ; } ( ) ) ;
2021-03-01 09:25:27 +01:00
/***/ } ) ,
2021-05-19 17:09:27 +02:00
/***/ 323 :
2021-04-15 17:19:43 +02:00
/***/ ( function ( module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
"use strict" ;
2021-05-19 17:09:27 +02:00
/* harmony import */ var _wordpress _element _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _ ( 0 ) ;
/* harmony import */ var _wordpress _element _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( _wordpress _element _ _WEBPACK _IMPORTED _MODULE _0 _ _ ) ;
/* harmony import */ var _wordpress _primitives _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _ ( 3 ) ;
/* harmony import */ var _wordpress _primitives _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( _wordpress _primitives _ _WEBPACK _IMPORTED _MODULE _1 _ _ ) ;
2021-04-15 17:19:43 +02:00
2021-05-19 17:09:27 +02:00
/ * *
* WordPress dependencies
* /
2021-04-15 17:19:43 +02:00
2021-05-19 17:09:27 +02:00
const reusableBlock = Object ( _wordpress _element _ _WEBPACK _IMPORTED _MODULE _0 _ _ [ "createElement" ] ) ( _wordpress _primitives _ _WEBPACK _IMPORTED _MODULE _1 _ _ [ "SVG" ] , {
xmlns : "http://www.w3.org/2000/svg" ,
viewBox : "0 0 24 24"
} , Object ( _wordpress _element _ _WEBPACK _IMPORTED _MODULE _0 _ _ [ "createElement" ] ) ( _wordpress _primitives _ _WEBPACK _IMPORTED _MODULE _1 _ _ [ "Path" ] , {
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"
} ) ) ;
/* harmony default export */ _ _webpack _exports _ _ [ "a" ] = ( reusableBlock ) ;
2021-04-15 17:19:43 +02:00
/***/ } ) ,
2021-05-19 17:09:27 +02:00
/***/ 36 :
2021-04-15 17:19:43 +02:00
/***/ ( function ( module , exports ) {
2021-05-19 17:09:27 +02:00
( function ( ) { module . exports = window [ "wp" ] [ "notices" ] ; } ( ) ) ;
2021-04-15 17:19:43 +02:00
/***/ } ) ,
2021-05-19 17:09:27 +02:00
/***/ 4 :
2020-10-20 15:36:16 +02:00
/***/ ( function ( module , exports ) {
2021-01-28 03:04:13 +01:00
( function ( ) { module . exports = window [ "wp" ] [ "components" ] ; } ( ) ) ;
2020-10-20 15:36:16 +02:00
/***/ } ) ,
2021-05-19 17:09:27 +02:00
/***/ 5 :
2020-10-20 15:36:16 +02:00
/***/ ( function ( module , exports ) {
2021-01-28 03:04:13 +01:00
( function ( ) { module . exports = window [ "wp" ] [ "data" ] ; } ( ) ) ;
2020-10-20 15:36:16 +02:00
/***/ } ) ,
2021-05-19 17:09:27 +02:00
/***/ 569 :
2020-10-20 15:36:16 +02:00
/***/ ( function ( module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
"use strict" ;
// ESM COMPAT FLAG
_ _webpack _require _ _ . r ( _ _webpack _exports _ _ ) ;
// EXPORTS
2021-01-28 03:04:13 +01:00
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "store" , function ( ) { return /* reexport */ store ; } ) ;
2020-10-20 15:36:16 +02:00
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "ReusableBlocksMenuItems" , function ( ) { return /* reexport */ reusable _blocks _menu _items ; } ) ;
// NAMESPACE OBJECT: ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js
var actions _namespaceObject = { } ;
_ _webpack _require _ _ . r ( actions _namespaceObject ) ;
_ _webpack _require _ _ . d ( actions _namespaceObject , "__experimentalConvertBlockToStatic" , function ( ) { return _ _experimentalConvertBlockToStatic ; } ) ;
_ _webpack _require _ _ . d ( actions _namespaceObject , "__experimentalConvertBlocksToReusable" , function ( ) { return _ _experimentalConvertBlocksToReusable ; } ) ;
_ _webpack _require _ _ . d ( actions _namespaceObject , "__experimentalDeleteReusableBlock" , function ( ) { return _ _experimentalDeleteReusableBlock ; } ) ;
_ _webpack _require _ _ . d ( actions _namespaceObject , "__experimentalSetEditingReusableBlock" , function ( ) { return _ _experimentalSetEditingReusableBlock ; } ) ;
// NAMESPACE OBJECT: ./node_modules/@wordpress/reusable-blocks/build-module/store/selectors.js
var selectors _namespaceObject = { } ;
_ _webpack _require _ _ . r ( selectors _namespaceObject ) ;
_ _webpack _require _ _ . d ( selectors _namespaceObject , "__experimentalIsEditingReusableBlock" , function ( ) { return _ _experimentalIsEditingReusableBlock ; } ) ;
2021-01-28 03:04:13 +01:00
// EXTERNAL MODULE: external ["wp","blockEditor"]
var external _wp _blockEditor _ = _ _webpack _require _ _ ( 6 ) ;
2020-10-20 15:36:16 +02:00
2021-01-28 03:04:13 +01:00
// EXTERNAL MODULE: external ["wp","coreData"]
2021-05-19 17:09:27 +02:00
var external _wp _coreData _ = _ _webpack _require _ _ ( 18 ) ;
2020-10-20 15:36:16 +02:00
2021-01-28 03:04:13 +01:00
// EXTERNAL MODULE: external ["wp","data"]
2021-05-19 17:09:27 +02:00
var external _wp _data _ = _ _webpack _require _ _ ( 5 ) ;
2020-10-20 15:36:16 +02:00
2021-03-01 09:25:27 +01:00
// EXTERNAL MODULE: external "lodash"
var external _lodash _ = _ _webpack _require _ _ ( 2 ) ;
2021-01-28 03:04:13 +01:00
// EXTERNAL MODULE: external ["wp","blocks"]
2021-05-19 17:09:27 +02:00
var external _wp _blocks _ = _ _webpack _require _ _ ( 8 ) ;
2020-10-20 15:36:16 +02:00
2021-01-28 03:04:13 +01:00
// EXTERNAL MODULE: external ["wp","i18n"]
var external _wp _i18n _ = _ _webpack _require _ _ ( 1 ) ;
2020-10-20 15:36:16 +02:00
// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/controls.js
2021-03-01 09:25:27 +01:00
/ * *
* External dependencies
* /
2020-10-20 15:36:16 +02:00
/ * *
* WordPress dependencies
* /
2021-03-01 09:25:27 +01:00
2021-05-19 17:09:27 +02:00
2021-01-28 03:04:13 +01:00
/ * *
* Internal dependencies
* /
2020-10-20 15:36:16 +02:00
/ * *
* Convert a reusable block to a static block effect handler
*
* @ param { string } clientId Block ID .
* @ return { Object } control descriptor .
* /
function convertBlockToStatic ( clientId ) {
return {
type : 'CONVERT_BLOCK_TO_STATIC' ,
2021-05-19 17:09:27 +02:00
clientId
2020-10-20 15:36:16 +02:00
} ;
}
/ * *
* Convert a static block to a reusable block effect handler
*
2021-04-15 17:19:43 +02:00
* @ param { Array } clientIds Block IDs .
* @ param { string } title Reusable block title .
2020-10-20 15:36:16 +02:00
* @ return { Object } control descriptor .
* /
2021-04-15 17:19:43 +02:00
function controls _convertBlocksToReusable ( clientIds , title ) {
2020-10-20 15:36:16 +02:00
return {
type : 'CONVERT_BLOCKS_TO_REUSABLE' ,
2021-05-19 17:09:27 +02:00
clientIds ,
title
2020-10-20 15:36:16 +02:00
} ;
}
/ * *
* Deletes a reusable block .
*
* @ param { string } id Reusable block ID .
* @ return { Object } control descriptor .
* /
2021-01-28 03:04:13 +01:00
function deleteReusableBlock ( id ) {
2020-10-20 15:36:16 +02:00
return {
type : 'DELETE_REUSABLE_BLOCK' ,
2021-05-19 17:09:27 +02:00
id
2020-10-20 15:36:16 +02:00
} ;
}
2021-05-19 17:09:27 +02:00
const controls = {
CONVERT _BLOCK _TO _STATIC : Object ( external _wp _data _ [ "createRegistryControl" ] ) ( registry => ( {
clientId
} ) => {
const oldBlock = registry . select ( external _wp _blockEditor _ [ "store" ] ) . getBlock ( clientId ) ;
const reusableBlock = registry . select ( 'core' ) . getEditedEntityRecord ( 'postType' , 'wp_block' , oldBlock . attributes . ref ) ;
const newBlocks = Object ( external _wp _blocks _ [ "parse" ] ) ( Object ( external _lodash _ [ "isFunction" ] ) ( reusableBlock . content ) ? reusableBlock . content ( reusableBlock ) : reusableBlock . content ) ;
registry . dispatch ( external _wp _blockEditor _ [ "store" ] ) . replaceBlocks ( oldBlock . clientId , newBlocks ) ;
2020-10-20 15:36:16 +02:00
} ) ,
2021-05-19 17:09:27 +02:00
CONVERT _BLOCKS _TO _REUSABLE : Object ( external _wp _data _ [ "createRegistryControl" ] ) ( registry => async function ( {
clientIds ,
title
} ) {
const reusableBlock = {
title : title || Object ( external _wp _i18n _ [ "__" ] ) ( 'Untitled Reusable block' ) ,
content : Object ( external _wp _blocks _ [ "serialize" ] ) ( registry . select ( external _wp _blockEditor _ [ "store" ] ) . getBlocksByClientId ( clientIds ) ) ,
status : 'publish'
} ;
const updatedRecord = await registry . dispatch ( 'core' ) . saveEntityRecord ( 'postType' , 'wp_block' , reusableBlock ) ;
const newBlock = Object ( external _wp _blocks _ [ "createBlock" ] ) ( 'core/block' , {
ref : updatedRecord . id
} ) ;
registry . dispatch ( external _wp _blockEditor _ [ "store" ] ) . replaceBlocks ( clientIds , newBlock ) ;
registry . dispatch ( store ) . _ _experimentalSetEditingReusableBlock ( newBlock . clientId , true ) ;
2020-10-20 15:36:16 +02:00
} ) ,
2021-05-19 17:09:27 +02:00
DELETE _REUSABLE _BLOCK : Object ( external _wp _data _ [ "createRegistryControl" ] ) ( registry => async function ( {
id
} ) {
const reusableBlock = registry . select ( 'core' ) . getEditedEntityRecord ( 'postType' , 'wp_block' , id ) ; // Don't allow a reusable block with a temporary ID to be deleted
if ( ! reusableBlock ) {
return ;
} // Remove any other blocks that reference this reusable block
const allBlocks = registry . select ( external _wp _blockEditor _ [ "store" ] ) . getBlocks ( ) ;
const associatedBlocks = allBlocks . filter ( block => Object ( external _wp _blocks _ [ "isReusableBlock" ] ) ( block ) && block . attributes . ref === id ) ;
const associatedBlockClientIds = associatedBlocks . map ( block => block . clientId ) ; // Remove the parsed block.
if ( associatedBlockClientIds . length ) {
registry . dispatch ( external _wp _blockEditor _ [ "store" ] ) . removeBlocks ( associatedBlockClientIds ) ;
}
await registry . dispatch ( 'core' ) . deleteEntityRecord ( 'postType' , 'wp_block' , id ) ;
2020-10-20 15:36:16 +02:00
} )
} ;
/* harmony default export */ var store _controls = ( controls ) ;
// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js
/ * *
* Internal dependencies
* /
/ * *
* Returns a generator converting a reusable block into a static block .
*
* @ param { string } clientId The client ID of the block to attach .
* /
2021-05-19 17:09:27 +02:00
function * _ _experimentalConvertBlockToStatic ( clientId ) {
yield convertBlockToStatic ( clientId ) ;
2020-10-20 15:36:16 +02:00
}
/ * *
* Returns a generator converting one or more static blocks into a reusable block .
*
* @ param { string [ ] } clientIds The client IDs of the block to detach .
2021-04-15 17:19:43 +02:00
* @ param { string } title Reusable block title .
2020-10-20 15:36:16 +02:00
* /
2021-05-19 17:09:27 +02:00
function * _ _experimentalConvertBlocksToReusable ( clientIds , title ) {
yield controls _convertBlocksToReusable ( clientIds , title ) ;
2020-10-20 15:36:16 +02:00
}
/ * *
* Returns a generator deleting a reusable block .
*
* @ param { string } id The ID of the reusable block to delete .
* /
2021-05-19 17:09:27 +02:00
function * _ _experimentalDeleteReusableBlock ( id ) {
yield deleteReusableBlock ( id ) ;
2020-10-20 15:36:16 +02:00
}
/ * *
* Returns an action descriptor for SET _EDITING _REUSABLE _BLOCK action .
*
* @ param { string } clientId The clientID of the reusable block to target .
* @ param { boolean } isEditing Whether the block should be in editing state .
* @ return { Object } Action descriptor .
* /
function _ _experimentalSetEditingReusableBlock ( clientId , isEditing ) {
return {
type : 'SET_EDITING_REUSABLE_BLOCK' ,
2021-05-19 17:09:27 +02:00
clientId ,
isEditing
2020-10-20 15:36:16 +02:00
} ;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/reducer.js
/ * *
* WordPress dependencies
* /
2021-05-19 17:09:27 +02:00
function isEditingReusableBlock ( state = { } , action ) {
2020-10-20 15:36:16 +02:00
if ( ( action === null || action === void 0 ? void 0 : action . type ) === 'SET_EDITING_REUSABLE_BLOCK' ) {
2021-05-19 17:09:27 +02:00
return { ... state ,
[ action . clientId ] : action . isEditing
} ;
2020-10-20 15:36:16 +02:00
}
return state ;
}
2021-01-28 03:04:13 +01:00
/* harmony default export */ var reducer = ( Object ( external _wp _data _ [ "combineReducers" ] ) ( {
2021-05-19 17:09:27 +02:00
isEditingReusableBlock
2020-10-20 15:36:16 +02:00
} ) ) ;
// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/selectors.js
/ * *
* Returns true if reusable block is in the editing state .
*
* @ param { Object } state Global application state .
* @ param { number } clientId the clientID of the block .
* @ return { boolean } Whether the reusable block is in the editing state .
* /
function _ _experimentalIsEditingReusableBlock ( state , clientId ) {
return state . isEditingReusableBlock [ clientId ] ;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/index.js
/ * *
* WordPress dependencies
* /
/ * *
* Internal dependencies
* /
2021-05-19 17:09:27 +02:00
const STORE _NAME = 'core/reusable-blocks' ;
2020-10-20 15:36:16 +02:00
/ * *
2021-01-28 03:04:13 +01:00
* Store definition for the reusable blocks namespace .
2020-10-20 15:36:16 +02:00
*
2021-02-02 06:17:13 +01:00
* @ see https : //github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
2020-10-20 15:36:16 +02:00
*
* @ type { Object }
* /
2021-05-19 17:09:27 +02:00
const store = Object ( external _wp _data _ [ "createReduxStore" ] ) ( STORE _NAME , {
2020-10-20 15:36:16 +02:00
actions : actions _namespaceObject ,
controls : store _controls ,
reducer : reducer ,
selectors : selectors _namespaceObject
2021-01-28 03:04:13 +01:00
} ) ;
Object ( external _wp _data _ [ "register" ] ) ( store ) ;
2020-10-20 15:36:16 +02:00
2021-01-28 03:04:13 +01:00
// EXTERNAL MODULE: external ["wp","element"]
var external _wp _element _ = _ _webpack _require _ _ ( 0 ) ;
2020-10-20 15:36:16 +02:00
2021-01-28 03:04:13 +01:00
// EXTERNAL MODULE: external ["wp","components"]
2021-05-19 17:09:27 +02:00
var external _wp _components _ = _ _webpack _require _ _ ( 4 ) ;
2020-10-20 15:36:16 +02:00
2021-05-19 17:09:27 +02:00
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/reusable-block.js
var reusable _block = _ _webpack _require _ _ ( 323 ) ;
2020-10-20 15:36:16 +02:00
2021-01-28 03:04:13 +01:00
// EXTERNAL MODULE: external ["wp","notices"]
2021-05-19 17:09:27 +02:00
var external _wp _notices _ = _ _webpack _require _ _ ( 36 ) ;
2021-01-28 03:04:13 +01:00
2020-10-20 15:36:16 +02:00
// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-block-convert-button.js
/ * *
* WordPress dependencies
* /
2021-01-28 03:04:13 +01:00
2020-10-20 15:36:16 +02:00
/ * *
* Internal dependencies
* /
/ * *
* Menu control to convert block ( s ) to reusable block .
*
* @ param { Object } props Component props .
* @ param { string [ ] } props . clientIds Client ids of selected blocks .
* @ param { string } props . rootClientId ID of the currently selected top - level block .
* @ return { import ( '@wordpress/element' ) . WPComponent } The menu control or null .
* /
2021-05-19 17:09:27 +02:00
function ReusableBlockConvertButton ( {
clientIds ,
rootClientId
} ) {
const [ isModalOpen , setIsModalOpen ] = Object ( external _wp _element _ [ "useState" ] ) ( false ) ;
const [ title , setTitle ] = Object ( external _wp _element _ [ "useState" ] ) ( '' ) ;
const canConvert = Object ( external _wp _data _ [ "useSelect" ] ) ( select => {
2020-10-20 15:36:16 +02:00
var _getBlocksByClientId ;
2021-05-19 17:09:27 +02:00
const {
canUser
} = select ( 'core' ) ;
const {
getBlocksByClientId ,
canInsertBlockType
} = select ( 'core/block-editor' ) ;
const blocks = ( _getBlocksByClientId = getBlocksByClientId ( clientIds ) ) !== null && _getBlocksByClientId !== void 0 ? _getBlocksByClientId : [ ] ;
const isReusable = blocks . length === 1 && blocks [ 0 ] && Object ( external _wp _blocks _ [ "isReusableBlock" ] ) ( blocks [ 0 ] ) && ! ! select ( 'core' ) . getEntityRecord ( 'postType' , 'wp_block' , blocks [ 0 ] . attributes . ref ) ;
const _canConvert = // Hide when this is already a reusable block.
2020-10-20 15:36:16 +02:00
! isReusable && // Hide when reusable blocks are disabled.
2021-05-19 17:09:27 +02:00
canInsertBlockType ( 'core/block' , rootClientId ) && blocks . every ( block => // Guard against the case where a regular block has *just* been converted.
! ! block && // Hide on invalid blocks.
block . isValid && // Hide when block doesn't support being made reusable.
Object ( external _wp _blocks _ [ "hasBlockSupport" ] ) ( block . name , 'reusable' , true ) ) && // Hide when current doesn't have permission to do that.
2020-10-20 15:36:16 +02:00
! ! canUser ( 'create' , 'blocks' ) ;
return _canConvert ;
} , [ clientIds ] ) ;
2021-05-19 17:09:27 +02:00
const {
_ _experimentalConvertBlocksToReusable : convertBlocksToReusable
} = Object ( external _wp _data _ [ "useDispatch" ] ) ( store ) ;
const {
createSuccessNotice ,
createErrorNotice
} = Object ( external _wp _data _ [ "useDispatch" ] ) ( external _wp _notices _ [ "store" ] ) ;
const onConvert = Object ( external _wp _element _ [ "useCallback" ] ) ( async function ( reusableBlockTitle ) {
try {
await convertBlocksToReusable ( clientIds , reusableBlockTitle ) ;
createSuccessNotice ( Object ( external _wp _i18n _ [ "__" ] ) ( 'Reusable block created.' ) , {
type : 'snackbar'
} ) ;
} catch ( error ) {
createErrorNotice ( error . message , {
type : 'snackbar'
} ) ;
}
} , [ clientIds ] ) ;
2020-10-20 15:36:16 +02:00
if ( ! canConvert ) {
return null ;
}
2021-05-19 17:09:27 +02:00
return Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _blockEditor _ [ "BlockSettingsMenuControls" ] , null , ( {
onClose
} ) => Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _element _ [ "Fragment" ] , null , Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "MenuItem" ] , {
icon : reusable _block [ "a" /* default */ ] ,
onClick : ( ) => {
setIsModalOpen ( true ) ;
}
} , Object ( external _wp _i18n _ [ "__" ] ) ( 'Add to Reusable blocks' ) ) , isModalOpen && Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "Modal" ] , {
title : Object ( external _wp _i18n _ [ "__" ] ) ( 'Create Reusable block' ) ,
closeLabel : Object ( external _wp _i18n _ [ "__" ] ) ( 'Close' ) ,
onRequestClose : ( ) => {
setIsModalOpen ( false ) ;
setTitle ( '' ) ;
} ,
overlayClassName : "reusable-blocks-menu-items__convert-modal"
} , Object ( external _wp _element _ [ "createElement" ] ) ( "form" , {
onSubmit : event => {
event . preventDefault ( ) ;
onConvert ( title ) ;
setIsModalOpen ( false ) ;
setTitle ( '' ) ;
onClose ( ) ;
}
} , Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "TextControl" ] , {
label : Object ( external _wp _i18n _ [ "__" ] ) ( 'Name' ) ,
value : title ,
onChange : setTitle
} ) , Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "Flex" ] , {
className : "reusable-blocks-menu-items__convert-modal-actions" ,
justify : "flex-end"
} , Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "FlexItem" ] , null , Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "Button" ] , {
isSecondary : true ,
onClick : ( ) => {
setIsModalOpen ( false ) ;
setTitle ( '' ) ;
}
} , Object ( external _wp _i18n _ [ "__" ] ) ( 'Cancel' ) ) ) , Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "FlexItem" ] , null , Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "Button" ] , {
isPrimary : true ,
type : "submit"
} , Object ( external _wp _i18n _ [ "__" ] ) ( 'Save' ) ) ) ) ) ) ) ) ;
2020-10-20 15:36:16 +02:00
}
2021-01-28 03:04:13 +01:00
// EXTERNAL MODULE: external ["wp","url"]
2021-05-19 17:09:27 +02:00
var external _wp _url _ = _ _webpack _require _ _ ( 20 ) ;
2020-10-20 15:36:16 +02:00
2021-01-28 03:04:13 +01:00
// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js
2020-10-20 15:36:16 +02:00
/ * *
* WordPress dependencies
* /
2021-05-19 17:09:27 +02:00
function ReusableBlocksManageButton ( {
clientId
} ) {
const {
isVisible
} = Object ( external _wp _data _ [ "useSelect" ] ) ( select => {
const {
getBlock
} = select ( external _wp _blockEditor _ [ "store" ] ) ;
const {
canUser
} = select ( 'core' ) ;
const reusableBlock = getBlock ( clientId ) ;
2020-10-20 15:36:16 +02:00
return {
2021-01-28 03:04:13 +01:00
isVisible : ! ! reusableBlock && Object ( external _wp _blocks _ [ "isReusableBlock" ] ) ( reusableBlock ) && ! ! canUser ( 'update' , 'blocks' , reusableBlock . attributes . ref )
2020-10-20 15:36:16 +02:00
} ;
2021-05-19 17:09:27 +02:00
} , [ clientId ] ) ;
2020-10-20 15:36:16 +02:00
if ( ! isVisible ) {
return null ;
}
2021-01-28 03:04:13 +01:00
return Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _blockEditor _ [ "BlockSettingsMenuControls" ] , null , Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "MenuItem" ] , {
href : Object ( external _wp _url _ [ "addQueryArgs" ] ) ( 'edit.php' , {
post _type : 'wp_block'
} )
} , Object ( external _wp _i18n _ [ "__" ] ) ( 'Manage Reusable blocks' ) ) ) ;
2020-10-20 15:36:16 +02:00
}
2021-01-28 03:04:13 +01:00
/* harmony default export */ var reusable _blocks _manage _button = ( ReusableBlocksManageButton ) ;
2020-10-20 15:36:16 +02:00
// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/index.js
/ * *
* WordPress dependencies
* /
2021-05-19 17:09:27 +02:00
2020-10-20 15:36:16 +02:00
/ * *
* Internal dependencies
* /
2021-05-19 17:09:27 +02:00
function ReusableBlocksMenuItems ( {
clientIds ,
rootClientId
} ) {
2021-01-28 03:04:13 +01:00
return Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _element _ [ "Fragment" ] , null , Object ( external _wp _element _ [ "createElement" ] ) ( ReusableBlockConvertButton , {
2020-10-20 15:36:16 +02:00
clientIds : clientIds ,
rootClientId : rootClientId
2021-01-28 03:04:13 +01:00
} ) , clientIds . length === 1 && Object ( external _wp _element _ [ "createElement" ] ) ( reusable _blocks _manage _button , {
2020-10-20 15:36:16 +02:00
clientId : clientIds [ 0 ]
} ) ) ;
}
2021-05-19 17:09:27 +02:00
/* harmony default export */ var reusable _blocks _menu _items = ( Object ( external _wp _data _ [ "withSelect" ] ) ( select => {
const {
getSelectedBlockClientIds
} = select ( external _wp _blockEditor _ [ "store" ] ) ;
2020-10-20 15:36:16 +02:00
return {
clientIds : getSelectedBlockClientIds ( )
} ;
} ) ( ReusableBlocksMenuItems ) ) ;
// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/index.js
// CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/index.js
/ * *
* WordPress dependencies
* /
/***/ } ) ,
2021-01-28 03:04:13 +01:00
/***/ 6 :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = window [ "wp" ] [ "blockEditor" ] ; } ( ) ) ;
/***/ } ) ,
2021-05-19 17:09:27 +02:00
/***/ 8 :
2020-10-20 15:36:16 +02:00
/***/ ( function ( module , exports ) {
2021-01-28 03:04:13 +01:00
( function ( ) { module . exports = window [ "wp" ] [ "blocks" ] ; } ( ) ) ;
2020-10-20 15:36:16 +02:00
/***/ } )
/******/ } ) ;