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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-blockly-component

v3.3.0

Published

A React wrapper for the Blockly visual programming editor

Downloads

64

Readme

react-blockly-component

A React component that embeds a Blockly visual programming editor.

Features:

  • Supports an xmlDidChange prop so other components can easily consume the XML generated by the editor
  • Generates the toolbox XML from a toolboxCategories or toolboxBlocks prop, and automatically notifies Blockly when it's been updated

Building

Clone this repository, and then inside it, do:

npm install
npm run build

You'll get a dist directory containing the compiled JS file and a source map.

Properties

All properties are optional except where otherwise specified.

  • initialXml: The XML of the program to initially load in the editor.
  • workspaceConfiguration: Any configuration options to be passed into Blockly.inject (except for toolbox, which is handled automatically).
  • wrapperDivClassName: The value for the class attribute to be used on the <div> elements generated by this component. Typically you'll need to use this to set the height of the Blockly editor, using either an explicit height style, flexboxes, or some other means.
  • toolboxCategories: An array of categories for the toolbox. Each category is an object including the following properties:
    • name: The display name of this category.
    • custom: The value for the custom attribute of this category (can be either "VARIABLE" or "PROCEDURE").
    • categories: An array of subcategories, each of which follows the same format as this object.
    • blocks: An array of blocks to appear in the category. Each block is an object including the following properties:
      • type (required): The Blockly type name for the block (such as "controls_if" or "logic_compare").
      • colour: If present, gives a custom colour value for the block.
      • shadow: True if this is a shadow block; false or undefined otherwise.
      • fields: An object mapping from field names to pre-set values for those fields.
      • values: An object mapping from value input names to pre-set connected blocks for those value inputs. Each block is an object following the same format as this one.
      • statements: An object mapping from statement input names to pre-set connected blocks for those statement inputs. Each block is an object following the same format as this one.
      • next: The next block connected to this one, which is an object following the same format as this one.
      • mutation: An object specifying the content of the <mutation> tag for this block, with the following properties:
        • attributes: An object mapping from attribute names to values for those attributes.
        • innerContent: The XML content of the <mutation> tag in string format.
  • toolboxBlocks: An array of top-level blocks for the toolbox. Each block is an object following the format of the objects in the toolboxCategories blocks array (specified above). If this property is defined, toolboxCategories should not be defined, since Blockly's toolbox can either contain blocks or categories, but not both.
  • workspaceDidChange: A callback function that will be fired for every workspace event. Take a look at https://developers.google.com/blockly/guides/configure/web/events for a full list of events. For example you can handle your clientside code generation in this function. The new workspace object will be passed as an argument to the function.
  • processToolboxCategory: A callback function that can be used to pre-process the content of a toolbox category. This function is passed a single object (an Immutable.js Map) from the toolboxCategories array and is expected to return an object of the same format. This is useful if another React component is embedding BlocklyEditor and wants to add dynamic content to the toolbox.

Example usage

See public/index.html for a fairly full-fledged demo that shows off most of the features of this component.

Contributing

We accept pull requests and issues! You can file an issue on this project, or fork, modify, and file a pull request.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Licensing

react-blockly-component is Copyright © 2015 PatientsLikeMe, Inc. Distributed under the terms and conditions of the MIT License.