1.0.34 • Published 2 years ago

@blockly/block-extension-tooltip v1.0.34

Weekly downloads
42
License
Apache 2.0
Repository
github
Last release
2 years ago

@blockly/block-extension-tooltip Built on Blockly

A Blockly block extension that adds support for custom tooltip rendering.

WARNING: This plugin is deprecated. It is not compatible with recent versions of Blockly (v7.20211209.0 or above). As of Blockly v8, this plugin is no longer necessary as Blockly supports custom tooltip rendering. For an example, see the custom tooltip demo. Please uninstall this plugin and update Blockly to v8 or above. This plugin may be removed in the future.

Note:

  • This plugin uses a block extension and as a result, it needs to be added to each block type. See test/index.ts
  • This plugin is monkeypatching Blockly. It is not guaranteed to continue to function.

Installation

Yarn

yarn add @blockly/block-extension-tooltip

npm

npm install @blockly/block-extension-tooltip --save

Usage

npm.io

Register

Register the tooltip extension:

import * as Blockly from 'blockly';
import {registerTooltipExtension} from '@blockly/block-extension-tooltip';

registerTooltipExtension((block) => {
  // Custom tooltip rendering method.
  const el = document.createElement('div');
  el.className = 'my-custom-tooltip';
  el.textContent = block.getTooltip();
  return el;
}, 'custom-tooltip-extension');

Block definition

Add the extension to your block definition using JSON:

Blockly.defineBlocksWithJsonArray([
  {
    "type": "my-block",
    "extensions": ["custom-tooltip-extension"]
  }
]);

or add the extension to your block definition using JavaScript:

Blockly.Blocks['my-block'] = {
  init: function() {
    Blockly.Extensions.apply('custom-tooltip-extension', this, false);
  },
};

License

Apache 2.0

1.0.34

2 years ago

1.0.20

2 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.11

3 years ago

1.0.12

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago