PencilCode / pencilcode

An online IDE for kids: pencilcode.net.
http://dev.pencilcode.net/
MIT License
167 stars 100 forks source link

Blocks for adding elements to array #249

Open aolney opened 5 years ago

aolney commented 5 years ago

I'm using a custom blocks palette and have a block for an array of objects (ELIZA rules):

rules = 
  [ 
    { pattern: /(.*)you remember(.*)/, position: 2, response: 'Do you often think of #'}
  ]

Pedagogically I'd like to give this block as an example and then another block with a rule template:

{ pattern: /``/, position: ``, response: ``}

The problem is that although I can make this block appear in the palette, it does not have a "notch" and so will not drag/drop into the correct insertion point in the rules array. This block instead is a a "flat" block typical of parameters.

I have a work around for this which is to use an IIFE, but pedagogically that is not so nice:

do -> return { pattern: /``/, position: ``, response: ``}

This drag/drops with the desired behavior.

It seems obvious this is a UI issue, so if there is a way of forcing notches from the palette itself, I could solve the problem that way.