Skip to content

Instantly share code, notes, and snippets.

@nirkaufman
Created January 26, 2022 19:07
Show Gist options
  • Select an option

  • Save nirkaufman/a28b62dabfad1d78d2cfd4472db71923 to your computer and use it in GitHub Desktop.

Select an option

Save nirkaufman/a28b62dabfad1d78d2cfd4472db71923 to your computer and use it in GitHub Desktop.
import { Component, ViewEncapsulation } from '@angular/core';
import { NgxBlocklyConfig, NgxBlocklyGenerator } from 'ngx-blockly';
@Component({
selector: 'app-root',
template: `
<h1>Demo</h1>
<ngx-blockly [config]="config" (javascriptCode)="onCode($event)"></ngx-blockly>
`,
styles: [`
ngx-blockly {
position: absolute;
width: 100%;
height: 100%;
}
`]
})
export class AppComponent {
title = 'blockly-demo';
public config: NgxBlocklyConfig = {
toolbox:
'<xml id="toolbox" style="display: none">' +
'<category name="Logic" colour="%{BKY_LOGIC_HUE}">' +
'<block type="controls_if"></block>' +
'<block type="controls_repeat_ext"></block>' +
'<block type="logic_compare"></block>' +
'<block type="math_number_property"></block>' +
'<block type="math_number"></block>' +
'<block type="math_arithmetic"></block>' +
'<block type="text"></block>' +
'<block type="text_print"></block>' +
"</category>" +
"</xml>",
trashcan: true,
generators: [
NgxBlocklyGenerator.DART,
NgxBlocklyGenerator.LUA,
NgxBlocklyGenerator.JAVASCRIPT,
NgxBlocklyGenerator.PHP,
NgxBlocklyGenerator.PYTHON,
NgxBlocklyGenerator.XML
],
defaultBlocks: true,
move: {
scrollbars: true,
wheel: true
}
};
onCode($event: string) {
}
}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { NgxBlocklyModule } from 'ngx-blockly';
import "blockly/blocks";
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
NgxBlocklyModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment