Membuat jenis input baru

Untuk membuat input kustom, Anda harus membuat subclass Input, atau salah satu subclass-nya.

class MyInput extends Blockly.inputs.Input {

  // The constructor should always take in a name and a block to be compatible
  // with JSON block definitions.
  constructor(name, block) {
    super(name, block);
    // etc...
  }
}

Jika perlu, buat koneksi

Jika Anda ingin input Anda memiliki koneksi, input tersebut harus dibuat di konstruktor, dengan memanggil metode makeConnection.

constructor(name, block) {
  super(name, block);

  this.connection = this.makeConnection(ConnectionType.INPUT_VALUE);
}

Mendaftarkan input

Agar dapat menggunakan input kustom dalam definisi blok JSON, Anda harus mendaftarkannya dan mengaitkannya dengan string.

class MyInput extends Blockly.inputs.Input {}

Blockly.registry.register(Blockly.registry.Type.INPUT, 'my_input', MyInput);