Reference
JavaScript API
Reference, generated from the plugin source
The globals GCB puts on window in the editor for themes and plugins to use, read from src/.
window.gcbLiteControls
Where a field type's editor component is registered, for every GCB field editor on the page (the block editor, the post-fields meta box and the sidebar panel). Loaded by the gcblite-control-hub script.
| Method | Description |
|---|---|
register( type, component, options = {} ) | Params: (string) type the field type, as in block.fields.json; (Function|Object) component a React component (function, memo or forwardRef); (Object) [options]; (boolean) [options.override] replace a built-in / GCB control of the same name |
if( ! ok ) | |
get( type ) | The component registered for a type, or undefined. |
types( ) | Every type registered here. |
subscribe( fn ) | Hear about every registration — the ones already made, then each new one. Params: (Function) fn ( type, { component, override } ) |
if( i !== -1 ) |
window.gcbLiteEditor
The editor bridge: what a block's own editor.js draws its overlay through (see Drawing on a block in the editor).
| Member | Description |
|---|---|
canvas | The canvas document — for an overlay that needs it outside a render. |
version | The bridge's version: overlays can check for what they need. |
The ctx an overlay's render receives has: clientId, doc, element, block, children, selectedId, select, update, rerender.
Window events
| Event | detail | Dispatched in |
|---|---|---|
gcblite:preview-rendered | clientId, blockName | src/hooks/usePHPPreview.js |