Socket
Book a DemoInstallSign in
Socket

@blockly/block-extension-tooltip

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blockly/block-extension-tooltip

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

latest
Source
npmnpm
Version
1.0.34
Version published
Maintainers
2
Created
Source

@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

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

Keywords

blockly

FAQs

Package last updated on 04 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts