Hi! I'm new to Blockly, but I've read all relevant documentation in my frantic search to find the solution. I'm using the add_text block example from sample app and I'm getting the browser error:
Uncaught TypeError: Invalid block definition for type: add_text /**
* @license
* Copyright 2023 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import * as Blockly from 'blockly/core';
// Create a custom block called 'add_text' that adds
// text to the output div on the sample app.
// This is just an example and you should replace this with your
// own custom blocks.
const addText = {
type: 'add_text',
message0: 'Add text %1',
args0: [
{
type: 'input_value',
name: 'TEXT',
check: 'String',
},
],
previousStatement: null,
nextStatement: null,
colour: 160,
tooltip: '',
helpUrl: '',
};
// Create the block definitions for the JSON-only blocks.
// This does not register their definitions with Blockly.
// This file has no side effects!
export const blocks = Blockly.common.createBlockDefinitionsFromJsonArray([
addText,
]);
Here is my index.html:
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Blockly Demo: Toolbox</title>
<script src="./node_modules/blockly/blockly_compressed.js"></script>
<script src="./node_modules/blockly/blocks_compressed.js"></script>
<script src="./node_modules/blockly/msg/en.js"></script>
<style>
body {
background-color: #fff;
font-family: sans-serif;
}
h1 {
font-weight: normal;
font-size: 140%;
}
</style>
</head>
<body>
<p>This is a demo of the SnapBot Editor</p>
<div id="blocklyDiv" style="height: 600px"></div>
<script type="module">
import { toolbox } from './src/toolbox.js';
import { theme } from './src/darktheme.js';
var demoWorkspace = Blockly.inject('blocklyDiv', {
move:{
scrollbars: {
horizontal: true,
vertical: true
},
drag: true,
wheel: true},
grid:
{spacing: 50,
length: 5,
colour: '#ccc',
snap: true},
media: './node_modules/blockly/media/',
theme: theme,
toolbox: toolbox,
zoom:
{controls: true,
wheel: true,
startScale: 1.0,
maxScale: 3,
minScale: 0.3,
scaleSpeed: 1.2,
pinch: true},
});
</script>
</body>
</html>```The error throws when I click into the math menu (which is where I put add text while testing) in the toolbar.
{
kind: 'block',
type: 'add_text',
},
Yes, my paths are correct, that's how I have it set up, I know it's weird but that's not the issue. Any and all help appreciated. Thanks in advance.