2022-04-11 14:04:30 +02:00
/******/ ( function ( ) { // webpackBootstrap
/******/ "use strict" ;
/******/ // The require scope
/******/ var _ _webpack _require _ _ = { } ;
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ ! function ( ) {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ _ _webpack _require _ _ . n = function ( module ) {
/******/ var getter = module && module . _ _esModule ?
/******/ function ( ) { return module [ 'default' ] ; } :
/******/ function ( ) { return module ; } ;
/******/ _ _webpack _require _ _ . d ( getter , { a : getter } ) ;
/******/ return getter ;
/******/ } ;
/******/ } ( ) ;
/******/
/******/ /* webpack/runtime/define property getters */
/******/ ! function ( ) {
/******/ // define getter functions for harmony exports
/******/ _ _webpack _require _ _ . d = function ( exports , definition ) {
/******/ for ( var key in definition ) {
/******/ if ( _ _webpack _require _ _ . o ( definition , key ) && ! _ _webpack _require _ _ . o ( exports , key ) ) {
/******/ Object . defineProperty ( exports , key , { enumerable : true , get : definition [ key ] } ) ;
/******/ }
/******/ }
2018-12-14 05:41:57 +01:00
/******/ } ;
2022-04-11 14:04:30 +02:00
/******/ } ( ) ;
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ ! function ( ) {
/******/ _ _webpack _require _ _ . o = function ( obj , prop ) { return Object . prototype . hasOwnProperty . call ( obj , prop ) ; }
/******/ } ( ) ;
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ ! function ( ) {
/******/ // 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 } ) ;
/******/ } ;
/******/ } ( ) ;
/******/
2018-12-14 05:41:57 +01:00
/************************************************************************/
2022-04-11 14:04:30 +02:00
var _ _webpack _exports _ _ = { } ;
2020-06-29 13:50:29 +02:00
// ESM COMPAT FLAG
2018-12-14 05:41:57 +01:00
_ _webpack _require _ _ . r ( _ _webpack _exports _ _ ) ;
2018-12-18 04:14:52 +01:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: external ["wp","element"]
var external _wp _element _namespaceObject = window [ "wp" ] [ "element" ] ;
; // CONCATENATED MODULE: external ["wp","i18n"]
var external _wp _i18n _namespaceObject = window [ "wp" ] [ "i18n" ] ;
2023-02-07 08:04:52 +01:00
; // CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.js
/ * ! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Copyright ( c ) Microsoft Corporation .
Permission to use , copy , modify , and / or distribute this software for any
purpose with or without fee is hereby granted .
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS . IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL , DIRECT ,
INDIRECT , OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE , DATA OR PROFITS , WHETHER IN AN ACTION OF CONTRACT , NEGLIGENCE OR
OTHER TORTIOUS ACTION , ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
/* global Reflect, Promise */
var extendStatics = function ( d , b ) {
extendStatics = Object . setPrototypeOf ||
( { _ _proto _ _ : [ ] } instanceof Array && function ( d , b ) { d . _ _proto _ _ = b ; } ) ||
function ( d , b ) { for ( var p in b ) if ( Object . prototype . hasOwnProperty . call ( b , p ) ) d [ p ] = b [ p ] ; } ;
return extendStatics ( d , b ) ;
} ;
function _ _extends ( d , b ) {
if ( typeof b !== "function" && b !== null )
throw new TypeError ( "Class extends value " + String ( b ) + " is not a constructor or null" ) ;
extendStatics ( d , b ) ;
function _ _ ( ) { this . constructor = d ; }
d . prototype = b === null ? Object . create ( b ) : ( _ _ . prototype = b . prototype , new _ _ ( ) ) ;
}
var _ _assign = function ( ) {
_ _assign = Object . assign || function _ _assign ( t ) {
for ( var s , i = 1 , n = arguments . length ; i < n ; i ++ ) {
s = arguments [ i ] ;
for ( var p in s ) if ( Object . prototype . hasOwnProperty . call ( s , p ) ) t [ p ] = s [ p ] ;
}
return t ;
}
return _ _assign . apply ( this , arguments ) ;
}
function _ _rest ( s , e ) {
var t = { } ;
for ( var p in s ) if ( Object . prototype . hasOwnProperty . call ( s , p ) && e . indexOf ( p ) < 0 )
t [ p ] = s [ p ] ;
if ( s != null && typeof Object . getOwnPropertySymbols === "function" )
for ( var i = 0 , p = Object . getOwnPropertySymbols ( s ) ; i < p . length ; i ++ ) {
if ( e . indexOf ( p [ i ] ) < 0 && Object . prototype . propertyIsEnumerable . call ( s , p [ i ] ) )
t [ p [ i ] ] = s [ p [ i ] ] ;
}
return t ;
}
function _ _decorate ( decorators , target , key , desc ) {
var c = arguments . length , r = c < 3 ? target : desc === null ? desc = Object . getOwnPropertyDescriptor ( target , key ) : desc , d ;
if ( typeof Reflect === "object" && typeof Reflect . decorate === "function" ) r = Reflect . decorate ( decorators , target , key , desc ) ;
else for ( var i = decorators . length - 1 ; i >= 0 ; i -- ) if ( d = decorators [ i ] ) r = ( c < 3 ? d ( r ) : c > 3 ? d ( target , key , r ) : d ( target , key ) ) || r ;
return c > 3 && r && Object . defineProperty ( target , key , r ) , r ;
}
function _ _param ( paramIndex , decorator ) {
return function ( target , key ) { decorator ( target , key , paramIndex ) ; }
}
function _ _metadata ( metadataKey , metadataValue ) {
if ( typeof Reflect === "object" && typeof Reflect . metadata === "function" ) return Reflect . metadata ( metadataKey , metadataValue ) ;
}
function _ _awaiter ( thisArg , _arguments , P , generator ) {
function adopt ( value ) { return value instanceof P ? value : new P ( function ( resolve ) { resolve ( value ) ; } ) ; }
return new ( P || ( P = Promise ) ) ( function ( resolve , reject ) {
function fulfilled ( value ) { try { step ( generator . next ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
function rejected ( value ) { try { step ( generator [ "throw" ] ( value ) ) ; } catch ( e ) { reject ( e ) ; } }
function step ( result ) { result . done ? resolve ( result . value ) : adopt ( result . value ) . then ( fulfilled , rejected ) ; }
step ( ( generator = generator . apply ( thisArg , _arguments || [ ] ) ) . next ( ) ) ;
} ) ;
}
function _ _generator ( thisArg , body ) {
var _ = { label : 0 , sent : function ( ) { if ( t [ 0 ] & 1 ) throw t [ 1 ] ; return t [ 1 ] ; } , trys : [ ] , ops : [ ] } , f , y , t , g ;
return g = { next : verb ( 0 ) , "throw" : verb ( 1 ) , "return" : verb ( 2 ) } , typeof Symbol === "function" && ( g [ Symbol . iterator ] = function ( ) { return this ; } ) , g ;
function verb ( n ) { return function ( v ) { return step ( [ n , v ] ) ; } ; }
function step ( op ) {
if ( f ) throw new TypeError ( "Generator is already executing." ) ;
while ( _ ) try {
if ( f = 1 , y && ( t = op [ 0 ] & 2 ? y [ "return" ] : op [ 0 ] ? y [ "throw" ] || ( ( t = y [ "return" ] ) && t . call ( y ) , 0 ) : y . next ) && ! ( t = t . call ( y , op [ 1 ] ) ) . done ) return t ;
if ( y = 0 , t ) op = [ op [ 0 ] & 2 , t . value ] ;
switch ( op [ 0 ] ) {
case 0 : case 1 : t = op ; break ;
case 4 : _ . label ++ ; return { value : op [ 1 ] , done : false } ;
case 5 : _ . label ++ ; y = op [ 1 ] ; op = [ 0 ] ; continue ;
case 7 : op = _ . ops . pop ( ) ; _ . trys . pop ( ) ; continue ;
default :
if ( ! ( t = _ . trys , t = t . length > 0 && t [ t . length - 1 ] ) && ( op [ 0 ] === 6 || op [ 0 ] === 2 ) ) { _ = 0 ; continue ; }
if ( op [ 0 ] === 3 && ( ! t || ( op [ 1 ] > t [ 0 ] && op [ 1 ] < t [ 3 ] ) ) ) { _ . label = op [ 1 ] ; break ; }
if ( op [ 0 ] === 6 && _ . label < t [ 1 ] ) { _ . label = t [ 1 ] ; t = op ; break ; }
if ( t && _ . label < t [ 2 ] ) { _ . label = t [ 2 ] ; _ . ops . push ( op ) ; break ; }
if ( t [ 2 ] ) _ . ops . pop ( ) ;
_ . trys . pop ( ) ; continue ;
}
op = body . call ( thisArg , _ ) ;
} catch ( e ) { op = [ 6 , e ] ; y = 0 ; } finally { f = t = 0 ; }
if ( op [ 0 ] & 5 ) throw op [ 1 ] ; return { value : op [ 0 ] ? op [ 1 ] : void 0 , done : true } ;
}
}
var _ _createBinding = Object . create ? ( function ( o , m , k , k2 ) {
if ( k2 === undefined ) k2 = k ;
Object . defineProperty ( o , k2 , { enumerable : true , get : function ( ) { return m [ k ] ; } } ) ;
} ) : ( function ( o , m , k , k2 ) {
if ( k2 === undefined ) k2 = k ;
o [ k2 ] = m [ k ] ;
} ) ;
function _ _exportStar ( m , o ) {
for ( var p in m ) if ( p !== "default" && ! Object . prototype . hasOwnProperty . call ( o , p ) ) _ _createBinding ( o , m , p ) ;
}
function _ _values ( o ) {
var s = typeof Symbol === "function" && Symbol . iterator , m = s && o [ s ] , i = 0 ;
if ( m ) return m . call ( o ) ;
if ( o && typeof o . length === "number" ) return {
next : function ( ) {
if ( o && i >= o . length ) o = void 0 ;
return { value : o && o [ i ++ ] , done : ! o } ;
}
} ;
throw new TypeError ( s ? "Object is not iterable." : "Symbol.iterator is not defined." ) ;
}
function _ _read ( o , n ) {
var m = typeof Symbol === "function" && o [ Symbol . iterator ] ;
if ( ! m ) return o ;
var i = m . call ( o ) , r , ar = [ ] , e ;
try {
while ( ( n === void 0 || n -- > 0 ) && ! ( r = i . next ( ) ) . done ) ar . push ( r . value ) ;
}
catch ( error ) { e = { error : error } ; }
finally {
try {
if ( r && ! r . done && ( m = i [ "return" ] ) ) m . call ( i ) ;
}
finally { if ( e ) throw e . error ; }
}
return ar ;
}
/** @deprecated */
function _ _spread ( ) {
for ( var ar = [ ] , i = 0 ; i < arguments . length ; i ++ )
ar = ar . concat ( _ _read ( arguments [ i ] ) ) ;
return ar ;
}
/** @deprecated */
function _ _spreadArrays ( ) {
for ( var s = 0 , i = 0 , il = arguments . length ; i < il ; i ++ ) s += arguments [ i ] . length ;
for ( var r = Array ( s ) , k = 0 , i = 0 ; i < il ; i ++ )
for ( var a = arguments [ i ] , j = 0 , jl = a . length ; j < jl ; j ++ , k ++ )
r [ k ] = a [ j ] ;
return r ;
}
function _ _spreadArray ( to , from , pack ) {
if ( pack || arguments . length === 2 ) for ( var i = 0 , l = from . length , ar ; i < l ; i ++ ) {
if ( ar || ! ( i in from ) ) {
if ( ! ar ) ar = Array . prototype . slice . call ( from , 0 , i ) ;
ar [ i ] = from [ i ] ;
}
}
return to . concat ( ar || Array . prototype . slice . call ( from ) ) ;
}
function _ _await ( v ) {
return this instanceof _ _await ? ( this . v = v , this ) : new _ _await ( v ) ;
}
function _ _asyncGenerator ( thisArg , _arguments , generator ) {
if ( ! Symbol . asyncIterator ) throw new TypeError ( "Symbol.asyncIterator is not defined." ) ;
var g = generator . apply ( thisArg , _arguments || [ ] ) , i , q = [ ] ;
return i = { } , verb ( "next" ) , verb ( "throw" ) , verb ( "return" ) , i [ Symbol . asyncIterator ] = function ( ) { return this ; } , i ;
function verb ( n ) { if ( g [ n ] ) i [ n ] = function ( v ) { return new Promise ( function ( a , b ) { q . push ( [ n , v , a , b ] ) > 1 || resume ( n , v ) ; } ) ; } ; }
function resume ( n , v ) { try { step ( g [ n ] ( v ) ) ; } catch ( e ) { settle ( q [ 0 ] [ 3 ] , e ) ; } }
function step ( r ) { r . value instanceof _ _await ? Promise . resolve ( r . value . v ) . then ( fulfill , reject ) : settle ( q [ 0 ] [ 2 ] , r ) ; }
function fulfill ( value ) { resume ( "next" , value ) ; }
function reject ( value ) { resume ( "throw" , value ) ; }
function settle ( f , v ) { if ( f ( v ) , q . shift ( ) , q . length ) resume ( q [ 0 ] [ 0 ] , q [ 0 ] [ 1 ] ) ; }
}
function _ _asyncDelegator ( o ) {
var i , p ;
return i = { } , verb ( "next" ) , verb ( "throw" , function ( e ) { throw e ; } ) , verb ( "return" ) , i [ Symbol . iterator ] = function ( ) { return this ; } , i ;
function verb ( n , f ) { i [ n ] = o [ n ] ? function ( v ) { return ( p = ! p ) ? { value : _ _await ( o [ n ] ( v ) ) , done : n === "return" } : f ? f ( v ) : v ; } : f ; }
}
function _ _asyncValues ( o ) {
if ( ! Symbol . asyncIterator ) throw new TypeError ( "Symbol.asyncIterator is not defined." ) ;
var m = o [ Symbol . asyncIterator ] , i ;
return m ? m . call ( o ) : ( o = typeof _ _values === "function" ? _ _values ( o ) : o [ Symbol . iterator ] ( ) , i = { } , verb ( "next" ) , verb ( "throw" ) , verb ( "return" ) , i [ Symbol . asyncIterator ] = function ( ) { return this ; } , i ) ;
function verb ( n ) { i [ n ] = o [ n ] && function ( v ) { return new Promise ( function ( resolve , reject ) { v = o [ n ] ( v ) , settle ( resolve , reject , v . done , v . value ) ; } ) ; } ; }
function settle ( resolve , reject , d , v ) { Promise . resolve ( v ) . then ( function ( v ) { resolve ( { value : v , done : d } ) ; } , reject ) ; }
}
function _ _makeTemplateObject ( cooked , raw ) {
if ( Object . defineProperty ) { Object . defineProperty ( cooked , "raw" , { value : raw } ) ; } else { cooked . raw = raw ; }
return cooked ;
} ;
var _ _setModuleDefault = Object . create ? ( function ( o , v ) {
Object . defineProperty ( o , "default" , { enumerable : true , value : v } ) ;
} ) : function ( o , v ) {
o [ "default" ] = v ;
} ;
function _ _importStar ( mod ) {
if ( mod && mod . _ _esModule ) return mod ;
var result = { } ;
if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . prototype . hasOwnProperty . call ( mod , k ) ) _ _createBinding ( result , mod , k ) ;
_ _setModuleDefault ( result , mod ) ;
return result ;
}
function _ _importDefault ( mod ) {
return ( mod && mod . _ _esModule ) ? mod : { default : mod } ;
}
function _ _classPrivateFieldGet ( receiver , state , kind , f ) {
if ( kind === "a" && ! f ) throw new TypeError ( "Private accessor was defined without a getter" ) ;
if ( typeof state === "function" ? receiver !== state || ! f : ! state . has ( receiver ) ) throw new TypeError ( "Cannot read private member from an object whose class did not declare it" ) ;
return kind === "m" ? f : kind === "a" ? f . call ( receiver ) : f ? f . value : state . get ( receiver ) ;
}
function _ _classPrivateFieldSet ( receiver , state , value , kind , f ) {
if ( kind === "m" ) throw new TypeError ( "Private method is not writable" ) ;
if ( kind === "a" && ! f ) throw new TypeError ( "Private accessor was defined without a setter" ) ;
if ( typeof state === "function" ? receiver !== state || ! f : ! state . has ( receiver ) ) throw new TypeError ( "Cannot write private member to an object whose class did not declare it" ) ;
return ( kind === "a" ? f . call ( receiver , value ) : f ? f . value = value : state . set ( receiver , value ) ) , value ;
}
; // CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js
/ * *
* Source : ftp : //ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
* /
var SUPPORTED _LOCALE = {
tr : {
regexp : /\u0130|\u0049|\u0049\u0307/g ,
map : {
İ : "\u0069" ,
I : "\u0131" ,
I ̇ : "\u0069" ,
} ,
} ,
az : {
regexp : /\u0130/g ,
map : {
İ : "\u0069" ,
I : "\u0131" ,
I ̇ : "\u0069" ,
} ,
} ,
lt : {
regexp : /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g ,
map : {
I : "\u0069\u0307" ,
J : "\u006A\u0307" ,
Į : "\u012F\u0307" ,
Ì : "\u0069\u0307\u0300" ,
Í : "\u0069\u0307\u0301" ,
Ĩ : "\u0069\u0307\u0303" ,
} ,
} ,
} ;
/ * *
* Localized lower case .
* /
function localeLowerCase ( str , locale ) {
var lang = SUPPORTED _LOCALE [ locale . toLowerCase ( ) ] ;
if ( lang )
return lowerCase ( str . replace ( lang . regexp , function ( m ) { return lang . map [ m ] ; } ) ) ;
return lowerCase ( str ) ;
}
/ * *
* Lower case as a function .
* /
function lowerCase ( str ) {
return str . toLowerCase ( ) ;
}
; // CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js
// Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
var DEFAULT _SPLIT _REGEXP = [ /([a-z0-9])([A-Z])/g , /([A-Z])([A-Z][a-z])/g ] ;
// Remove all non-word characters.
var DEFAULT _STRIP _REGEXP = /[^A-Z0-9]+/gi ;
/ * *
* Normalize the string into something other libraries can manipulate easier .
* /
function noCase ( input , options ) {
if ( options === void 0 ) { options = { } ; }
var _a = options . splitRegexp , splitRegexp = _a === void 0 ? DEFAULT _SPLIT _REGEXP : _a , _b = options . stripRegexp , stripRegexp = _b === void 0 ? DEFAULT _STRIP _REGEXP : _b , _c = options . transform , transform = _c === void 0 ? lowerCase : _c , _d = options . delimiter , delimiter = _d === void 0 ? " " : _d ;
var result = replace ( replace ( input , splitRegexp , "$1\0$2" ) , stripRegexp , "\0" ) ;
var start = 0 ;
var end = result . length ;
// Trim the delimiter from around the output string.
while ( result . charAt ( start ) === "\0" )
start ++ ;
while ( result . charAt ( end - 1 ) === "\0" )
end -- ;
// Transform each token independently.
return result . slice ( start , end ) . split ( "\0" ) . map ( transform ) . join ( delimiter ) ;
}
/ * *
* Replace ` re ` in the input string with the replacement value .
* /
function replace ( input , re , value ) {
if ( re instanceof RegExp )
return input . replace ( re , value ) ;
return re . reduce ( function ( input , re ) { return input . replace ( re , value ) ; } , input ) ;
}
; // CONCATENATED MODULE: ./node_modules/dot-case/dist.es2015/index.js
function dotCase ( input , options ) {
if ( options === void 0 ) { options = { } ; }
return noCase ( input , _ _assign ( { delimiter : "." } , options ) ) ;
}
; // CONCATENATED MODULE: ./node_modules/param-case/dist.es2015/index.js
function paramCase ( input , options ) {
if ( options === void 0 ) { options = { } ; }
return dotCase ( input , _ _assign ( { delimiter : "-" } , options ) ) ;
}
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: external ["wp","apiFetch"]
var external _wp _apiFetch _namespaceObject = window [ "wp" ] [ "apiFetch" ] ;
var external _wp _apiFetch _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( external _wp _apiFetch _namespaceObject ) ;
; // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/file.js
2018-12-18 04:14:52 +01:00
/ * *
* Downloads a file .
*
* @ param { string } fileName File Name .
* @ param { string } content File Content .
* @ param { string } contentType File mime type .
* /
function download ( fileName , content , contentType ) {
2021-05-19 17:09:27 +02:00
const file = new window . Blob ( [ content ] , {
2018-12-18 04:14:52 +01:00
type : contentType
} ) ; // IE11 can't use the click to download technique
// we use a specific IE11 technique instead.
if ( window . navigator . msSaveOrOpenBlob ) {
window . navigator . msSaveOrOpenBlob ( file , fileName ) ;
} else {
2021-05-19 17:09:27 +02:00
const a = document . createElement ( 'a' ) ;
2018-12-18 04:14:52 +01:00
a . href = URL . createObjectURL ( file ) ;
a . download = fileName ;
a . style . display = 'none' ;
document . body . appendChild ( a ) ;
a . click ( ) ;
document . body . removeChild ( a ) ;
}
}
/ * *
* Reads the textual content of the given file .
*
2021-11-08 15:29:21 +01:00
* @ param { File } file File .
2018-12-18 04:14:52 +01:00
* @ return { Promise < string > } Content of the file .
* /
function readTextFile ( file ) {
2021-05-19 17:09:27 +02:00
const reader = new window . FileReader ( ) ;
return new Promise ( resolve => {
reader . onload = ( ) => {
2018-12-18 04:14:52 +01:00
resolve ( reader . result ) ;
} ;
reader . readAsText ( file ) ;
} ) ;
}
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/export.js
2018-12-14 05:41:57 +01:00
/ * *
* External dependencies
* /
/ * *
* WordPress dependencies
* /
/ * *
* Internal dependencies
* /
2018-12-18 04:14:52 +01:00
/ * *
* Export a reusable block as a JSON file .
*
* @ param { number } id
* /
2018-12-14 05:41:57 +01:00
2021-05-19 17:09:27 +02:00
async function exportReusableBlock ( id ) {
const postType = await external _wp _apiFetch _default ( ) ( {
path : ` /wp/v2/types/wp_block `
} ) ;
const post = await external _wp _apiFetch _default ( ) ( {
path : ` /wp/v2/ ${ postType . rest _base } / ${ id } ?context=edit `
} ) ;
const title = post . title . raw ;
const content = post . content . raw ;
const fileContent = JSON . stringify ( {
_ _file : 'wp_block' ,
title ,
content
} , null , 2 ) ;
2023-02-07 08:04:52 +01:00
const fileName = paramCase ( title ) + '.json' ;
2021-05-19 17:09:27 +02:00
download ( fileName , fileContent , 'application/json' ) ;
2018-12-18 04:14:52 +01:00
}
2018-12-14 05:41:57 +01:00
2018-12-18 04:14:52 +01:00
/* harmony default export */ var utils _export = ( exportReusableBlock ) ;
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: external ["wp","compose"]
var external _wp _compose _namespaceObject = window [ "wp" ] [ "compose" ] ;
2023-02-07 08:04:52 +01:00
; // CONCATENATED MODULE: external ["wp","components"]
var external _wp _components _namespaceObject = window [ "wp" ] [ "components" ] ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/import.js
2018-12-18 04:14:52 +01:00
/ * *
* WordPress dependencies
* /
2018-12-14 05:41:57 +01:00
/ * *
* Internal dependencies
* /
2018-12-18 04:14:52 +01:00
/ * *
* Import a reusable block from a JSON file .
*
2021-11-08 15:29:21 +01:00
* @ param { File } file File .
2018-12-18 04:14:52 +01:00
* @ return { Promise } Promise returning the imported reusable block .
* /
2018-12-14 05:41:57 +01:00
2021-05-19 17:09:27 +02:00
async function importReusableBlock ( file ) {
const fileContent = await readTextFile ( file ) ;
let parsedContent ;
2018-12-18 04:14:52 +01:00
2021-05-19 17:09:27 +02:00
try {
parsedContent = JSON . parse ( fileContent ) ;
} catch ( e ) {
throw new Error ( 'Invalid JSON file' ) ;
}
2022-09-20 17:43:29 +02:00
if ( parsedContent . _ _file !== 'wp_block' || ! parsedContent . title || ! parsedContent . content || typeof parsedContent . title !== 'string' || typeof parsedContent . content !== 'string' ) {
2021-05-19 17:09:27 +02:00
throw new Error ( 'Invalid Reusable block JSON file' ) ;
}
const postType = await external _wp _apiFetch _default ( ) ( {
path : ` /wp/v2/types/wp_block `
} ) ;
const reusableBlock = await external _wp _apiFetch _default ( ) ( {
path : ` /wp/v2/ ${ postType . rest _base } ` ,
data : {
title : parsedContent . title ,
content : parsedContent . content ,
status : 'publish'
} ,
method : 'POST'
} ) ;
return reusableBlock ;
2018-12-18 04:14:52 +01:00
}
/* harmony default export */ var utils _import = ( importReusableBlock ) ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/components/import-form/index.js
2018-12-18 04:14:52 +01:00
/ * *
* WordPress dependencies
* /
/ * *
* Internal dependencies
* /
2022-04-12 17:12:47 +02:00
function ImportForm ( _ref ) {
let {
instanceId ,
onUpload
} = _ref ;
const inputId = 'list-reusable-blocks-import-form-' + instanceId ;
const formRef = ( 0 , external _wp _element _namespaceObject . useRef ) ( ) ;
const [ isLoading , setIsLoading ] = ( 0 , external _wp _element _namespaceObject . useState ) ( false ) ;
const [ error , setError ] = ( 0 , external _wp _element _namespaceObject . useState ) ( null ) ;
const [ file , setFile ] = ( 0 , external _wp _element _namespaceObject . useState ) ( null ) ;
const onChangeFile = event => {
setFile ( event . target . files [ 0 ] ) ;
setError ( null ) ;
} ;
2021-05-19 17:09:27 +02:00
2022-04-12 17:12:47 +02:00
const onSubmit = event => {
2021-05-19 17:09:27 +02:00
event . preventDefault ( ) ;
2018-12-14 05:41:57 +01:00
2021-05-19 17:09:27 +02:00
if ( ! file ) {
return ;
}
2018-12-14 05:41:57 +01:00
2022-04-12 17:12:47 +02:00
setIsLoading ( {
2021-05-19 17:09:27 +02:00
isLoading : true
} ) ;
utils _import ( file ) . then ( reusableBlock => {
2022-04-12 17:12:47 +02:00
if ( ! formRef ) {
2018-12-14 05:41:57 +01:00
return ;
}
2022-04-12 17:12:47 +02:00
setIsLoading ( false ) ;
2021-05-19 17:09:27 +02:00
onUpload ( reusableBlock ) ;
2022-04-12 17:12:47 +02:00
} ) . catch ( errors => {
if ( ! formRef ) {
2021-05-19 17:09:27 +02:00
return ;
}
let uiMessage ;
2022-04-12 17:12:47 +02:00
switch ( errors . message ) {
2021-05-19 17:09:27 +02:00
case 'Invalid JSON file' :
2022-04-11 14:04:30 +02:00
uiMessage = ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Invalid JSON file' ) ;
2021-05-19 17:09:27 +02:00
break ;
case 'Invalid Reusable block JSON file' :
2022-04-11 14:04:30 +02:00
uiMessage = ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Invalid Reusable block JSON file' ) ;
2021-05-19 17:09:27 +02:00
break ;
default :
2022-04-11 14:04:30 +02:00
uiMessage = ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Unknown error' ) ;
2021-05-19 17:09:27 +02:00
}
2022-04-12 17:12:47 +02:00
setIsLoading ( false ) ;
setError ( uiMessage ) ;
2021-05-19 17:09:27 +02:00
} ) ;
2022-04-12 17:12:47 +02:00
} ;
2021-05-19 17:09:27 +02:00
2022-04-12 17:12:47 +02:00
const onDismissError = ( ) => {
setError ( null ) ;
} ;
2018-12-14 05:41:57 +01:00
2022-04-12 17:12:47 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( "form" , {
className : "list-reusable-blocks-import-form" ,
onSubmit : onSubmit ,
ref : formRef
} , error && ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . Notice , {
status : "error" ,
onRemove : ( ) => onDismissError ( )
} , error ) , ( 0 , external _wp _element _namespaceObject . createElement ) ( "label" , {
htmlFor : inputId ,
className : "list-reusable-blocks-import-form__label"
} , ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'File' ) ) , ( 0 , external _wp _element _namespaceObject . createElement ) ( "input" , {
id : inputId ,
type : "file" ,
onChange : onChangeFile
} ) , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . Button , {
type : "submit" ,
isBusy : isLoading ,
disabled : ! file || isLoading ,
variant : "secondary" ,
className : "list-reusable-blocks-import-form__button"
} , ( 0 , external _wp _i18n _namespaceObject . _x ) ( 'Import' , 'button label' ) ) ) ;
2021-05-19 17:09:27 +02:00
}
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
/* harmony default export */ var import _form = ( ( 0 , external _wp _compose _namespaceObject . withInstanceId ) ( ImportForm ) ) ;
2018-12-14 05:41:57 +01:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/components/import-dropdown/index.js
2018-12-14 05:41:57 +01:00
2018-12-18 04:14:52 +01:00
/ * *
* WordPress dependencies
* /
2018-12-14 05:41:57 +01:00
2018-12-18 04:14:52 +01:00
/ * *
* Internal dependencies
* /
2021-11-15 13:50:17 +01:00
function ImportDropdown ( _ref ) {
let {
onUpload
} = _ref ;
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . Dropdown , {
2023-02-07 08:04:52 +01:00
popoverProps : {
placement : 'bottom-start'
} ,
2018-12-18 04:14:52 +01:00
contentClassName : "list-reusable-blocks-import-dropdown__content" ,
2021-11-15 13:50:17 +01:00
renderToggle : _ref2 => {
let {
isOpen ,
onToggle
} = _ref2 ;
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . Button , {
2021-11-15 13:50:17 +01:00
"aria-expanded" : isOpen ,
onClick : onToggle ,
variant : "primary"
2022-04-11 14:04:30 +02:00
} , ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Import from JSON' ) ) ;
2021-11-15 13:50:17 +01:00
} ,
renderContent : _ref3 => {
let {
onClose
} = _ref3 ;
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( import _form , {
2023-02-07 08:04:52 +01:00
onUpload : ( 0 , external _wp _compose _namespaceObject . pipe ) ( onClose , onUpload )
2021-11-15 13:50:17 +01:00
} ) ;
}
2018-12-18 04:14:52 +01:00
} ) ;
}
/* harmony default export */ var import _dropdown = ( ImportDropdown ) ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/index.js
2018-12-14 05:41:57 +01:00
/ * *
* WordPress dependencies
* /
/ * *
* Internal dependencies
* /
2022-04-12 17:12:47 +02:00
// Setup Export Links.
2018-12-14 05:41:57 +01:00
2021-05-19 17:09:27 +02:00
document . body . addEventListener ( 'click' , event => {
2018-12-14 05:41:57 +01:00
if ( ! event . target . classList . contains ( 'wp-list-reusable-blocks__export' ) ) {
return ;
}
event . preventDefault ( ) ;
2018-12-18 04:14:52 +01:00
utils _export ( event . target . dataset . id ) ;
2022-04-12 17:12:47 +02:00
} ) ; // Setup Import Form.
2018-12-14 05:41:57 +01:00
2021-05-19 17:09:27 +02:00
document . addEventListener ( 'DOMContentLoaded' , ( ) => {
const button = document . querySelector ( '.page-title-action' ) ;
2018-12-14 05:41:57 +01:00
if ( ! button ) {
return ;
}
2021-05-19 17:09:27 +02:00
const showNotice = ( ) => {
const notice = document . createElement ( 'div' ) ;
2018-12-14 05:41:57 +01:00
notice . className = 'notice notice-success is-dismissible' ;
2022-04-11 14:04:30 +02:00
notice . innerHTML = ` <p> ${ ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Reusable block imported successfully!' ) } </p> ` ;
2021-05-19 17:09:27 +02:00
const headerEnd = document . querySelector ( '.wp-header-end' ) ;
2018-12-14 05:41:57 +01:00
if ( ! headerEnd ) {
return ;
}
headerEnd . parentNode . insertBefore ( notice , headerEnd ) ;
} ;
2021-05-19 17:09:27 +02:00
const container = document . createElement ( 'div' ) ;
2018-12-14 05:41:57 +01:00
container . className = 'list-reusable-blocks__container' ;
button . parentNode . insertBefore ( container , button ) ;
2023-02-21 14:09:42 +01:00
( 0 , external _wp _element _namespaceObject . createRoot ) ( container ) . render ( ( 0 , external _wp _element _namespaceObject . createElement ) ( import _dropdown , {
2018-12-14 05:41:57 +01:00
onUpload : showNotice
2023-02-21 14:09:42 +01:00
} ) ) ;
2018-12-14 05:41:57 +01:00
} ) ;
2022-04-11 14:04:30 +02:00
( window . wp = window . wp || { } ) . listReusableBlocks = _ _webpack _exports _ _ ;
/******/ } ) ( )
;