Server IP : 192.158.238.246 / Your IP : 216.73.216.44 Web Server : LiteSpeed System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64 User : jenniferflocom ( 1321) PHP Version : 8.1.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/7779/task/7779/cwd/plugins/give/src/FormBuilder/resources/js/registrars/blocks/ |
Upload File : |
import {BlockConfiguration} from '@wordpress/blocks'; /** * @since 3.0.0 */ export interface Block { name: string; settings: BlockConfiguration; } /** * @since 3.0.0 */ interface Registrar { register(name: string, settings: BlockConfiguration): void; getAll(): Block[]; get(blockName: string): Block | undefined; } /** * @since 3.0.0 */ export default class BlockRegistrar implements Registrar { /** * @since 3.0.0 */ private blocks: Block[] = []; /** * @since 3.0.0 */ public get(blockName: string): Block | undefined { return this.blocks.find(({name}) => name === blockName); } /** * @since 3.0.0 */ public getAll(): Block[] { return this.blocks; } /** * @since 3.0.0 */ public register(name, settings: BlockConfiguration): void { if (this.get(name)) { throw new Error(`Block "${name}" is already registered.`); } this.blocks.push({name, settings}); } }