Constant provider

  • The ConstantProvider stores essential values like shapes, strings, and numbers used by Blockly's rendering components.

  • It defines standard shapes for different connection types, including notches for previous/next connections and puzzle tabs for input/output connections.

  • Connection shapes can be dynamically determined based on connection checks using the shapeFor method.

  • The ConstantProvider also defines paths for elements like collapsed block edges and various values for padding and minimum heights.

  • Modifying ConstantProvider values during runtime is discouraged as it can lead to rendering issues.

The ConstantProvider is a collection of magic numbers, shapes and strings used by all of the other renderer components, as well as other parts of Blockly like the built-in fields.

All constant values are assumed to be constant! Changing values at runtime causes rendering bugs.

Connection shapes

The constant provider contains definitions for the standard shapes of different connections. Notches define the shapes of next and previous connections. And the PuzzleTabs define the shapes of input and output connections. (These names are based on the shapes provided by the default renderer.)

Connection shapes based on checks

The constant provider can also define the shapes of connections dynamically based on their connection check. This is done using the shapeFor method.

Other various paths

The constant provider also defines paths for other various parts of the block, like jagged edges for collapsed blocks.

Other various values

And finally, the constant provider also defines various values for things like the padding between different elements, or the minimum heights of rows.