Package Exports
- @gechiui/block-library
- @gechiui/block-library/build-module/index.js
- @gechiui/block-library/build/index.js
- @gechiui/block-library/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@gechiui/block-library) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Block library
Block library for the GeChiUI editor.
Installation
Install the module
npm install @gechiui/block-library --saveThis package assumes that your code will run in an ES2015+ environment. If you're using an environment that has limited or no support for such language features and APIs, you should include the polyfill shipped in @gechiui/babel-preset-default in your code.
Building JavaScript for the browser
If a view.js file is present in the block's directory, this file will be built along other assets, making it available to load from the browser.
This enables us to, for instance, load this file when the block is present on the page in two ways:
- Using the block's
render_callback:
function render_block_my_block() {
$script_path = __DIR__ . '/my-block/view.js';
if ( file_exists( $script_path ) ) {
gc_enqueue_script(
'gc-block-my-block-view',
plugins_url( 'view.js', $script_path ),
array(),
false,
true
);
}
}
function register_block_my_block() {
register_block_type(
__DIR__ . '/my-block',
array(
'render_callback' => 'render_block_my_block',
)
);
}
add_action( 'init', 'register_block_my_block' );- Using the
render_blockfilter:
function render_block_my_block() {
$script_path = __DIR__ . '/my-block/view.js';
if ( file_exists( $script_path ) ) {
gc_enqueue_script(
'gc-block-my-block-view',
plugins_url( 'view.js', $script_path ),
array(),
false,
true
);
}
}
apply_filter( 'render_block', 'render_block_my_block' );API
registerCoreBlocks
Function to register core blocks provided by the block editor.
Usage
import { registerCoreBlocks } from '@gechiui/block-library';
registerCoreBlocks();Parameters
- blocks
Array: An optional array of the core blocks being registered.
