Détail du package

blockly

google155.2kApache-2.012.2.0

Blockly is a library for building visual programming editors.

blockly

readme

Blockly

Google's Blockly is a web-based, visual programming editor. Users can drag blocks together to build programs. All code is free and open source.

The source for this module is in the Blockly repo.

Example Usage

import * as Blockly from 'blockly/core';
Blockly.inject('blocklyDiv', {
    ...
})

Samples

For samples on how to integrate Blockly into your project, view the list of samples at blockly-samples.

Installation

You can install this package either via npm or unpkg.

unpkg

<script src="https://unpkg.com/blockly/blockly.min.js"></script>

When importing from unpkg, you can access imports from the global namespace.

// Access Blockly.
Blockly.thing;
// Access the default blocks.
Blockly.Blocks['block_type'];
// Access the javascript generator.
javascript.javascriptGenerator;

npm

npm install blockly

Imports

Note: Using import of our package targets requires you to use a bundler (like webpack), since Blockly is packaged as a UMD, rather than an ESM.

// Import Blockly core.
import * as Blockly from 'blockly/core';
// Import the default blocks.
import * as libraryBlocks from 'blockly/blocks';
// Import a generator.
import {javascriptGenerator} from 'blockly/javascript';
// Import a message file.
import * as En from 'blockly/msg/en';

Requires

// Require Blockly core.
const Blockly = require('blockly/core');
// Require the default blocks.
const libraryBlocks = require('blockly/blocks');
// Require a generator.
const {javascriptGenerator} = require('blockly/javascript');
// Require a message file.
const En = require('blockly/msg/en');

Applying messages

Once you have the message files, you also need to apply them.

Blockly.setLocal(En);

For a full list of supported Blockly locales, see: https://github.com/google/blockly/tree/master/msg/js

Docs

For more information about how to use Blockly, check out our devsite.

License

Apache 2.0

changelog

Changelog

8.0.0 (2022-03-31)

⚠ BREAKING CHANGES

  • change paste to return the pasted thing to support keyboard nav (#5996)
  • blocks: ...and rename Blockly.blocks.all (blocks/all.js) to Blockly.libraryBlocks (blocks/blocks.js
    • refactor(blocks): Make loopTypes a Set
  • allows previously internal constants to be configurable (#5897)
    • refactor(blocks): Make loopTypes a Set
  • remove unused constants from internalConstants (#5889)

Features

  • add mocha failure messages to console output (#5984) (7d250fa)
  • Allow developers to set a custom tooltip rendering function. (#5956) (6841ccc)
  • blocks: Export block definitions (#5908) (ffb8907)
  • make mocha fail if it encounters 0 tests (#5981) (0b2bf3a)
  • tests: Add a test to validate scripts/migration/renamings.js (#5980) (3c723f0)
  • tests: Use official semver.org RegExp (#5990) (afc4088)

Bug Fixes

  • Adds check for changedTouches (#5869) (3f4f505)
  • advanced playground and playground to work when hosted (#6021) (364bf14)
  • always rename caller to legal name (#6014) (c430800)
  • blocks: correct the callType_ of procedures_defreturn (#5974) (b34db5b)
  • build: Correctly handle deep export paths in UMD wrapper (#5945) (71ab146)
  • bumping a block after duplicate breaking undo (#5844) (5204569)
  • change getCandidate and showInsertionMarker to be more dynamic (#5722) (68d8113)
  • change paste to return the pasted thing to support keyboard nav (#5996) (20f1475)
  • Change the truthy tests of width and height in WorkspaceSvg.setCachedParentSvgSize to actual comparisons with null so that zero value can be saved into the cache (#5997) (fec44d9)
  • comments not being restored when dragging (#6011) (85ce3b8)
  • convert the common renderer to an ES6 class (#5978) (c1004be)
  • convert the Workspace class to an ES6 class (#5977) (e2eaebe)
  • custom block context menus (#5976) (8058df2)
  • Don't throw if drag surface is empty. (#5695) (769a25f)
  • export Blockly.Names.NameType and Blockly.Input.Align correctly (#6030) (2c15d00)
  • Export loopTypes from Blockly.blocks.loops (#5900) (4f74210)
  • Export loopTypes from Blockly.blocks.loops (#5900) (74ef1cb)
  • Fix bug where workspace comments could not be created. (#6024) (2cf8eb8)
  • Fix downloading screenshots on the playground. (#6025) (ca6e590)
  • fix keycodes type (#5805) (0a96543)
  • Fixed the label closure on demo/blockfactory (#5833) (e8ea2e9)
  • generators: Fix an operator precedence issue in the math_number_property generators to remove extra parentheses (#5685) (a31003f)
  • incorrect module for event data in renamings database (#6012) (e502eaa)
  • Move @alias onto classes instead of constructors (#6003) (1647a32)
  • move test helpers from samples into core (#5969) (2edd228)
  • move the dropdown div to a namespace instead of a class with only static properties (#5979) (543cb8e)
  • msg imports in type definitions (#5858) (07a75de)
  • opening/closing the mutators (#6000) (243fc52)
  • playground access to Blockly (9e1cda8)
  • playground test blocks, text area listeners, and show/hide buttons (#6015) (7abf3de)
  • procedure param edits breaking undo (#5845) (8a71f87)
  • re-expose HSV_VALUE and HSV_SATURATION as settable properties on Blockly (#5821) (0e5f3ce)
  • re-expose HSV_VALUE and HSV_SATURATION as settable properties on Blockly (#5821) (6fc3316)
  • revert "Delete events should animate when played (#5919)" (#6031) (c4a25eb)
  • revert converting test helpers to es modules (#5982) (01d4597)
  • setting null for a font style on a theme (#5831) (835fb02)
  • tests: Enable --debug for test:compile:advanced; fix some errors (#5959) (88334be)
  • tests: Enable --debug for test:compile:advanced; fix some errors (and demote the rest to warnings) (#5983) (e11b583)
  • TypeScript exporting of the serialization functions (#5890) (5d7c890)
  • undo/redo for auto disabling if-return blocks (#6018) (c7a359a)
  • update the playground to load compressed when hosted (#5835) (2adf326)
  • Update typings for q1 2022 release (#6051) (69f3d4a)
  • Use correct namespace for svgMath functions (#5813) (b8cc983)
  • Use correct namespace for svgMath functions (#5813) (025bab6)

Code Refactoring

  • allows previously internal constants to be configurable (#5897) (4b5733e)
  • blocks: Rename Blockly.blocks. modules to Blockly.libraryBlocks. (#5953) (5078dcb)
  • remove unused constants from internalConstants (#5889) (f0b1077)