File tree Expand file tree Collapse file tree 5 files changed +13
-13
lines changed
Expand file tree Collapse file tree 5 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ export class BlocklyCanvas extends HTMLElement {
5656 private workspaceChanged ( e : Blockly . Events . Ui ) {
5757 switch ( e . type ) {
5858 case Blockly . Events . CHANGE :
59- case Blockly . Events . DELETE :
59+ case Blockly . Events . BLOCK_DELETE :
6060 case Blockly . Events . MOVE :
6161 if ( ! this . typing ) this . generateCode ( )
6262 break
Original file line number Diff line number Diff line change 1- import * as SparqlJS from "sparqljs"
2- import * as SparqlBlockly from "sparql-blockly"
1+ import * as SparqlBlockly from "sparql-blockly"
32
43export class SparqlEditor extends HTMLElement {
54 private async connectedCallback ( ) {
@@ -36,26 +35,24 @@ export class SparqlEditor extends HTMLElement {
3635 const query = this . validate ( )
3736
3837 if ( query ) {
39- this . dispatchEvent ( new CustomEvent < Element > ( "sparql" , { detail : SparqlBlockly . sparqlToBlockly ( query ) } ) )
38+ this . dispatchEvent ( new CustomEvent < Element > ( "sparql" , { detail : query } ) )
4039 }
4140 }
4241
43- private validate ( ) : SparqlJS . SparqlQuery {
42+ private validate ( ) : Element {
4443 this . error = ""
4544 this . classList . remove ( "invalid" )
4645 this . classList . remove ( "valid" )
4746
4847 const sparql = this . value
4948
5049 if ( sparql ) {
51- const parser = new SparqlJS . Parser ( { sparqlStar : true } )
52-
5350 try {
54- const query = parser . parse ( sparql )
51+ const blocklyDom = SparqlBlockly . sparqlToBlockly ( sparql )
5552
5653 this . classList . add ( "valid" )
5754
58- return query
55+ return blocklyDom
5956 }
6057 catch ( e ) {
6158 this . error = e . message
Original file line number Diff line number Diff line change 11{
22 "name" : " sparql-blockly" ,
3- "version" : " 0.0.4-17 " ,
3+ "version" : " 0.0.4-18 " ,
44 "description" : " A library for working with SPARQL in Blockly" ,
55 "main" : " dist/index.js" ,
66 "license" : " MIT" ,
Original file line number Diff line number Diff line change @@ -4,8 +4,11 @@ import CodeGenerator from "./CodeGenerator"
44import * as SparqlJS from "sparqljs"
55import * as Blockly from "blockly"
66
7- export function sparqlToBlockly ( sparql : SparqlJS . SparqlQuery ) : Element {
8- return new BlockGenerator ( ) . visit ( sparql ) ?. xml
7+ export function sparqlToBlockly ( sparql : string ) : Element {
8+ const parser = new SparqlJS . Parser ( { sparqlStar : true } )
9+ const query = parser . parse ( sparql )
10+
11+ return new BlockGenerator ( ) . visit ( query ) ?. xml
912}
1013
1114// eslint-disable-next-line @typescript-eslint/no-explicit-any
You can’t perform that action at this time.
0 commit comments