blockly-samples icon indicating copy to clipboard operation
blockly-samples copied to clipboard

Add a plugin for core blocks that create shadows when mutated

Open BeksOmega opened this issue 5 years ago • 1 comments

Category

  • Plugins

Component

(new) block-shadow-mutators

Is your feature request related to a problem? Please describe.

Now that https://github.com/google/blockly/pull/4215 is merged it is possible to create mutators that generate shadow blocks. There are several blocks packaged with core Blockly that could benefit from this. They are:

  • math_number_property math_divisible_by
  • text_charAt text_charAt
  • text_getSubstring text_getSubstring
  • lists_getIndex lists_getIndex
  • lists_setIndex lists_setIndex
  • lists_getSublist lists_getSublist
  • and maybe logic_compare logic_compare

Describe the solution you'd like

I think that it might be nice to create a plugin that provides versions of these blocks where the mutators automatically create shadow blocks.

Describe alternatives you've considered

I've considered making changes to the blocks in the main repo, but that's a bad idea. Currently all shadow blocks are specified via XML, so people can use the core blocks without adding shadow blocks to their application. If we update these specific blocks to create shadows programmatically, it would automatically include shadows in any application using the core blocks, which may not be what developers want.

Additional context

The reason I didn't just go ahead and do this is that I'm not sure how often developers actually use the core blocks (rather than defining their own). So I'm not sure how often a plugin like this would get used.

BeksOmega avatar Sep 13 '20 19:09 BeksOmega

Another option: Create an extension that adds shadows to any empty inputs that accept strings or numbers. Then it can be applied not only to the core blocks, but also to any new blocks someone builds.

rachel-fenichel avatar Sep 14 '20 16:09 rachel-fenichel