Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: create plugin with renderer that treats dummy inputs as row separators. #1398

Merged
merged 13 commits into from
Dec 16, 2022
Merged

Conversation

johnnesky
Copy link
Member

Related to: google/blockly#2062

Creates a plugin that registers a renderer that treats dummy inputs as row separators. This is useful for putting adjacent inline value input connectors on separate rows, which was previously only possible for external value input connectors in the default renderer.

This plugin also defines some alternatives to built-in blocks that demonstrate the feature, and optionally allows overriding the built-in blocks themselves.

The renderer and the new block definitions override methods with names that end in an underscore, so I had to disable eslint for those names.

This plugin is a proof-of-concept. I suggest that Blockly should eventually support putting \n characters in block JSON message0 to accomplish the same effect. Note that I originally intended to create a renderer that supports indented external value input connectors, but decided that inline value input connectors are easier to implement and more idiomatic for some use-cases. (Although I still think that indented external value input connectors would be useful for growable lists of values.)

@johnnesky johnnesky requested a review from a team as a code owner December 3, 2022 05:13
@johnnesky johnnesky requested review from BeksOmega and removed request for a team December 3, 2022 05:13
@johnnesky
Copy link
Member Author

Beka pointed out that there's a request at google/blockly#216 for adding line-breaks between inline inputs (or in this case fields?) that I think could be addressed by this plugin.

Copy link
Contributor

@BeksOmega BeksOmega left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At a high level, I'm wondering if this would be better as a demo than a plugin? Since really, external devs might want to apply this to whatever their custom renderer is.

Inline I left a comment about using a decorator, which I think would also solve the problem of wanting to apply this to multiple renderers. But I don't think a decorator pattern makes sense when the RenderInfo interface is so large.

Besides that high level decision, looks really good! Also, thanks for going through and cleaning up the package.json, looks great =)

plugins/inline-row-separators/package.json Outdated Show resolved Hide resolved
plugins/inline-row-separators/test/index.ts Outdated Show resolved Hide resolved
plugins/inline-row-separators/package.json Outdated Show resolved Hide resolved
@johnnesky
Copy link
Member Author

I believe I was able to use TypeScript's mixin feature to allow this plugin to add the inline-row-separator feature to any Blockly Renderer!

@johnnesky johnnesky requested a review from BeksOmega December 16, 2022 01:19
Copy link
Contributor

@BeksOmega BeksOmega left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Approximately 50% nits and 50% compliments :P Thank you for your work on this John!

Once the nits are fixed up I'll merge this, and it'll either go out next Thursday, or before then if we can figure out #1452

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants