Stay organized with collections Save and categorize content based on your preferences.
Blockly lets you customize certain functionality by replacing the corresponding Blockly classes.
Replaceable classesThe following Blockly classes can be replaced:
For information about how to replace a renderer, see Create custom renderers.
Create a replacement classTo create a replacement class, implement the functions in the corresponding interface. You can implement all of these functions in a new class, or extend the Blockly class and only override the functions you want to change. The only requirement is that you (or the base class) implement all of the functions in the interface and adhere to any requirements described in comments on the interface.
To indicate to the type checker that you implement a specific interface, annotate your class with the @implements {InterfaceName}
JSDoc tag (in JavaScript) or the implements
keyword (in TypeScript).
There are two ways to tell Blockly about your replacement class: register it as the default class of its type (preferred) or inject it using the plugins
configuration option.
The preferred way to tell Blockly about your replacement class is to register it as the default for its type. To do this, call Blockly.registry.register
using the name Blockly.registry.DEFAULT
and set the opt_allowOverrides
parameter to true
.
Blockly.registry.register(
Blockly.registry.Type.VARIABLE_MODEL,
Blockly.registry.DEFAULT,
CustomVariableModel,
true,
);
Inject your replacement class
You can also inject replacement classes using the plugins
configuration option. This is an object that uses registry type names as property names and replacement classes or registered names as property values.
(In spite of the plugins
property's name, your class does not need to be packaged and distributed through npm like the plugins used to extend Blockly.)
Either pass your replacement class to Blockly.inject
:
Blockly.inject('blocklyDiv', {
plugins: {
'metricsManager': CustomMetricsManagerClass
}
}
Or register your class using Blockly.registry.register
and pass the registered name to Blockly.inject
. This is useful if you store your configuration options as pure JSON.
Blockly.registry.register(Blockly.registry.Type.METRICS_MANAGER, 'YOUR_NAME', CustomMetricsManagerClass);
Blockly.inject('blocklyDiv', {
plugins: {
'metricsManager': 'YOUR_NAME'
}
}
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-28 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-28 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4