import React from "react"; import { Block, Value, Field, Shadow, Category } from "../"; import { getColour } from "../helpers/colour"; import "@blockly/block-plus-minus"; import { TypedVariableModal } from "@blockly/plugin-typed-variable-modal"; import * as Blockly from "blockly/core"; class Toolbox extends React.Component { componentDidUpdate() { this.props.workspace.registerToolboxCategoryCallback( "CREATE_TYPED_VARIABLE", this.createFlyout ); const typedVarModal = new TypedVariableModal( this.props.workspace, "callbackName", [ [`${Blockly.Msg.variable_SHORT_NUMBER}`, "char"], [`${Blockly.Msg.variable_NUMBER}`, "int"], [`${Blockly.Msg.variable_LONG}`, "long"], [`${Blockly.Msg.variable_DECIMAL}`, "float"], [`${Blockly.Msg.variables_TEXT}`, "String"], [`${Blockly.Msg.variables_ARRAY}`, "Array"], [`${Blockly.Msg.variables_CHARACTER}`, "char"], [`${Blockly.Msg.variables_BOOLEAN}`, "boolean"], [`${Blockly.Msg.variables_NULL}`, "void"], [`${Blockly.Msg.variables_UNDEF}`, "undefined"], ] ); typedVarModal.init(); } createFlyout(workspace) { let xmlList = []; // Add your button and give it a callback name. const button = document.createElement("button"); button.setAttribute("text", "Create Typed Variable"); button.setAttribute("callbackKey", "callbackName"); xmlList.push(button); // This gets all the variables that the user creates and adds them to the // flyout. const blockList = Blockly.VariablesDynamic.flyoutCategoryBlocks(workspace); xmlList = xmlList.concat(blockList); return xmlList; } render() { return ( {/* */} 1 1 1 30 0 0 100 50 0 1 0 0 Title Unit Title Unit 0 15 0 50 5 0 15 0 0 0 0 0 0 0 latitude longitude altitude pDOP fixType {/* */} 10 1 10 1 1000 100 00 00 00 01 01 1970 {/* */} 1 1 100 1 100 220 100 {/* this block is the initial block of the workspace; not necessary to display, because it can only be used once anyway */} ); } } export default Toolbox;