npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rainbowmarket/field-text-input-flydown

v2.0.0

Published

Custom Blockly Input Fields with Flydown and Renderer Components

Readme

field_text_input_flydown badge@npm:@rainbowmarket/field-text-input-flydown

A custom Blockly field that provides a text input with a flydown menu.

You can see a demo version of a Blockly app that has integrated this plugin here. The code for that demo is here.

🚀 Installation

To install this library, run the following command:

npm i @rainbowmarket/field-text-input-flydown

Or include it via CDN:

<script src="https://unpkg.com/@rainbowmarket/field-text-input-flydown@latest"></script>

📌 Usage

1️⃣ Import the Library

ES Modules (Recommended)

import { FieldTextInputWithFlydown, FieldFlydown } from '@rainbowmarket/field_text_input_flydown';

CommonJS (Node.js)

const { FieldTextInputWithFlydown, FieldFlydown } = require('@rainbowmarket/field_text_input_flydown');

2️⃣ Define a Custom Block

You can define a block using either JavaScript or JSON.

Example XMLBlock String

const xmlData = `
  <xml>
    <!-- A block for getting the value of a variable -->
    <block type="variables_get">
      <field name="VAR">{{text}}</field>  <!-- {{text}} = Dynamic value retrieved from the field -->
    </block>

    <!-- A block for setting the value of a variable with a custom text input flydown -->
    <block type="variables_set">
      <field name="VAR">{{text}}</field>  <!-- {{text}} = Dynamic value retrieved from the field -->
    </block>
  </xml>
`

JavaScript Example

const custom_text_input = {
  init: function() {
    this.appendDummyInput('input')
      .appendField('FieldTextInputWithFlydown')
      .appendField(new FieldTextInputWithFlydown('item',/*optional*/ xmlData), 'TEXT');
    this.appendStatementInput('statement')
      .appendField('do');
    this.setTooltip('');
    this.setHelpUrl('');
    this.setColour(250);
  }
};
Blockly.common.defineBlocks({ custom_text_input: custom_text_input });

JSON Example

Blockly.defineBlocksWithJsonArray([
  {
    "type": "custom_text_input",
    "tooltip": "",
    "helpUrl": "",
    "message0": "FieldTextInputWithFlydown %1 %2 do %3",
    "args0": [
      {
        "type": "field_text_input_with_flydown",
        "name": "NAME",
        "text": "item",
        "xmlData": xmlData
      },
      {
        "type": "input_dummy",
        "name": "input"
      },
      {
        "type": "input_statement",
        "name": "statement"
      }
    ],
    "colour": 250
  }
]);

3️⃣ Initialize Blockly with the Custom Field

After defining the block, inject Blockly and initialize your custom field:

const workspace = Blockly.inject('blocklyDiv', {
  toolbox: document.getElementById('toolbox')
});
FieldFlydown.init(workspace);

📷 Example Block Image

Custom Block

🔧 Compatibility

Ensure that your Blockly version is 12.x (peer dependency ^12.0.0) for full compatibility.

📚 Explaining {{text}}

The {{text}} in the XML block definition is a placeholder for dynamically inserted text values that will be updated when interacting with the Blockly field. It represents a dynamic value that can be modified based on user input or logic in the Blockly environment. Specifically:

  • Dynamic Replacement: The {{text}} will be replaced by a value, which is typically retrieved from a custom field (e.g., FieldTextInputWithFlydown).
  • Custom Field Usage: In a custom Blockly field, like FieldTextInputWithFlydown, the text value will be retrieved and assigned dynamically, often using methods like this.getText().

For example:

<field name="VAR">{{text}}</field>  <!-- {{text}} = Dynamic value retrieved from the field -->

In this case, {{text}} will be populated by the value of the text input or flydown field, allowing the block to work interactively.

🤝 Contributing

Feel free to fork the repository and submit pull requests with improvements!

📜 License

This project is licensed under the MIT License.