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

@blockly/field-multilineinput

v6.0.8

Published

A Blockly multilineinput field.

Readme

@blockly/field-multilineinput Built on Blockly

A Blockly multiline input field and associated block.

Multiline input field

A block with the label "multiline text input:" and a multiline input field
with the text "default text \n with newline character.

Multiline input field with editor open

The same block with editor open.

Multiline input on collapsed block

The same block after being collapsed. It has the label "multiline text input:
defau..." and a jagged right edge to show it is collapsed.

Installation

Yarn

yarn add @blockly/field-multilineinput

npm

npm install @blockly/field-multilineinput --save

Usage

This plugin adds a field of type FieldMultilineInput that is registered with the name 'field_multilinetext'. It is a subclass of Blockly.FieldInput.

This field stores a string as its value and a string as its text. Its value is always a valid string, while its text could be any string entered into its editor. Unlike a text input field, this field also supports newline characters entered in the editor.

The constructor for this field accepts three optional parameters:

  • value: The default text. Defaults to "".
  • validator: A function that is called to validate what the user entered.
  • config: An object with three optional properties:
    • maxLines: The maximum number of lines displayed before scrolling functionality is enabled. Defaults to Infinity.
    • spellcheck: Whether spell checking is enabled. Defaults to true.
    • tooltip: A tooltip.

If you want to use only the field, you must register it with Blockly. You can do this by calling registerFieldMultilineInput before instantiating your blocks. If another field is registered under the same name, this field will overwrite it.

JavaScript

import * as Blockly from 'blockly';
import {registerFieldMultilineInput} from '@blockly/field-multilineinput';

registerFieldMultilineInput();
Blockly.Blocks['test_field_multilineinput'] = {
  init: function () {
    this.appendDummyInput()
      .appendField('multilineinput: ')
      .appendField(
        new FieldMultilineInput('some text \n with newlines'),
        'FIELDNAME',
      );
  },
};

JSON

import * as Blockly from 'blockly';
import {registerFieldMultilineInput} from '@blockly/field-multilineinput';

registerFieldMultilineInput();
Blockly.defineBlocksWithJsonArray([
    {
        "type": "test_field_multilinetext",
        "message0": "multilineinput: %1",
        "args0": [
            {
                "type": "field_multilinetext",
                "name": "FIELDNAME",
                "text": "some text \n with newlines"
            }
    }]);

Customization

Spellcheck

The setSpellcheck function can be used to set whether the field spellchecks its input text or not. Spellchecking is on by default.

An animation showing multiline text input fields with and without
spellcheck.

This applies to individual fields. If you want to modify all fields change the Blockly.FieldMultilineInput.prototype.spellcheck_ property.

Validation

A multiline text input field's value is a string, so any validators must accept a string and return a string, null, or undefined.

Here is an example of a validator that removes all 'a' characters from the string:

function(newValue) {
  return newValue.replace(/a/gm, '');
}

An animation showing validation.

Serialization

JSON

The JSON for a multiline text input field looks like so:

{
  "fields": {
    "FIELDNAME": "line1\nline2"
  }
}

where FIELDNAME is a string referencing a multiline text input field, and the value is the value to apply to the field. The value follows the same rules as the constructor value.

XML

The XML for a multiline text input field looks like so:

<field name="FIELDNAME">line1&amp;#10;line2</field>

where the field's name attribute contains a string referencing a multiline text input field, and the inner text is the value to apply to the field. The inner text value follows the same rules as the constructor value.

Blocks

This package also provides a simple block containing a multiline input field. It has generators in JavaScript, Python, PHP, Lua, and Dart.

You can install the block by calling textMultiline.installBlock(). This will install the block and all of its dependencies, including the multiline input field. When calling installBlock you can supply one or more CodeGenerator instances (e.g. javascriptGenerator), and the install function will also install the correct generator function for the corresponding language(s).

import {javascriptGenerator} from 'blockly/javascript';
import {dartGenerator} from 'blockly/dart';
import {phpGenerator} from 'blockly/php';
import {pythonGenerator} from 'blockly/python';
import {luaGenerator} from 'blockly/lua';
import {textMultiline} from '@blockly/field-multilineinput';

// Installs the block, the field, and all of the language generators.
textMultiline.installBlock({
  javascript: javascriptGenerator,
  dart: dartGenerator,
  lua: luaGenerator,
  python: pythonGenerator,
  php: phpGenerator,
});

API reference

  • setMaxLines: Sets the maximum number of displayed lines before scrolling functionality is enabled.
  • getMaxLines: Returns the maximum number of displayed lines before scrolling functionality is enabled.
  • setSpellcheck: Sets whether spell checking is enabled.
  • getSpellcheck: Returns whether spell checking is enabled.

License

Apache 2.0