balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

index.js (2233B)


      1 /**
      2  * BLOCK: Design Library
      3  */
      4 /**
      5  * External dependencies
      6  */
      7 import { ReduxTemplatesIcon } from '~redux-templates/icons'
      8 
      9 /**
     10  * Internal dependencies
     11  */
     12 import edit from './edit'
     13 import InsertLibraryButton from './insert-library-button'
     14 const { registerBlockType } = wp.blocks;
     15 
     16 /**
     17  * WordPress dependencies
     18  */
     19 import { __ } from '@wordpress/i18n'
     20 import domReady from '@wordpress/dom-ready'
     21 import { render } from '@wordpress/element'
     22 import { ReduxTemplatesIconColor } from '../../icons';
     23 
     24 
     25 
     26 const name = 'library';
     27 const icon = InsertLibraryButton
     28 
     29 const category = 'common';
     30 const schema = {}
     31 
     32 const title = __( 'Template Library', redux_templates.i18n );
     33 const description = __( 'Choose a section, template, or template kit from the Redux Template Library.', redux_templates.i18n );
     34 
     35 const keywords = [
     36 	__( 'Template Library', redux_templates.i18n ),
     37 	__( 'Design Library', redux_templates.i18n ),
     38 	__( 'Element Layouts', redux_templates.i18n ),
     39 	__( 'Redux', redux_templates.i18n ),
     40 ];
     41 
     42 const blockAttributes = {
     43 	file: {
     44 		type: 'object',
     45 	},
     46 };
     47 
     48 const settings = {
     49 	title: title,
     50 	description: description,
     51 	icon: ReduxTemplatesIconColor,
     52 	category: 'layout',
     53 	keywords: keywords,
     54 	attributes: schema,
     55 	supports: {
     56 		customClassName: false,
     57 		// inserter: ! disabledBlocks.includes( name ), // Hide if disabled.
     58 	},
     59 
     60 	example: {
     61 		attributes: {
     62 			// backgroundColor: '#000000',
     63 			// opacity: 0.8,
     64 
     65 			// padding: 30,
     66 			// textColor: '#FFFFFF',
     67 			// radius: 10,
     68 			// title: __( 'I am a slide title', 'wp-presenter-pro' ),
     69 		},
     70 	},
     71 
     72 	edit: edit,
     73 
     74 	save() {
     75 		return null;
     76 	},
     77 };
     78 
     79 const renderButton = function(toolbar) {
     80 
     81 	const buttonDiv = document.createElement( 'div' )
     82 	toolbar.appendChild( buttonDiv )
     83 
     84 	render( <InsertLibraryButton />, buttonDiv )
     85 }
     86 
     87 domReady( () => {
     88 	let toolbar = document.querySelector( '.edit-post-header__toolbar' );
     89 	if ( ! toolbar ) {
     90 		toolbar = document.querySelector( '.edit-post-header__toolbar' );
     91 	}
     92 	if ( ! toolbar ) {
     93 		setTimeout(function(){
     94 			let toolbar = document.querySelector( '.edit-post-header__toolbar' );
     95 			if ( toolbar ) {
     96 				renderButton( toolbar );
     97 			}
     98 		}, 500);
     99 		return;
    100 	}
    101 	renderButton(toolbar);
    102 } )
    103 
    104 export { name, title, category, icon, settings };