This is a demo of creating custom block fields. In this case the field is used to select a note pitch.
All of the custom field implementation is in demos/custom-fields/pitch/field_pitch.js, including comments on each required function.