-
Notifications
You must be signed in to change notification settings - Fork 84
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
Add support for context menus (#139) #144
Conversation
Please note that the implementation for Theia is provided in eclipse-sprotty/sprotty-theia#47 Unfortunately, these changes are a bit tedious to test as this change spans across sprotty and sprotty-theia, and then needs a Theia-based app that uses these changes. I've used https://github.com/eclipsesource/graphical-lsp/tree/context-menu-support for testing, but again it requires GLSP. Is there a up-to-date Theia app into which I could integrate this so you can test it more easily (via yarn link)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice.
As there are no tests, could you add a sample context menu to one of the examples?
Signed-off-by: Philip Langer <[email protected]>
Signed-off-by: Philip Langer <[email protected]>
Currently we only have an implementation of the Alternatively, I could implement the context menu service for plain HTML pages, but that'd require more effort and I'm not sure how useful this would be for real applications, as you'd typically would want to use the same context menu implementation that is also used in the surrounding app (e.g. react-based, angular-based, or whatever). Currently, this is already integrated in the GLSP workflow example, which is fairly simple. Ignoring server-provided menu items, this would look as follows:
|
Signed-off-by: Philip Langer <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with merging this to ease development in downstream projects and examples. We can still change (or even revert) things later.
One public example that would benefit from this feature is the npm dependencies viewer:
https://github.com/TypeFox/npm-dependency-graph
Could you add a context menu to the Theia extension in that example? Be careful not to break the standalone-app, which uses parts of the Sprotty code, but without Theia.
Also fixes types of `MenuItem` and adds docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One public example that would benefit from this feature is the npm dependencies viewer:
https://github.com/TypeFox/npm-dependency-graph
Could you add a context menu to the Theia extension in that example? Be careful not to break the standalone-app, which uses parts of the Sprotty code, but without Theia.
Ok, sure, I'll clone it and see if I manage to add a context menu there. I'll merge this and wait until it is available on npmjs to avoid headaches with yarn link and Theia (since both sprotty-theia and the npm-dependency-graph point to the next version). I'll open a PR once done.
Thanks! And happy new year! :-)
@spoenemann I've tried to integrate a context menu to npm-dependency-graph, but once I upgrade to the latest next versions of sprotty, sprotty-theia (and sprotty-elk), I get a couple of errors:
I can look through those errors and try to fix them, but I probably won't be able to do that until the week of the 7th of Jan. Are you planning to upgrade npm-dependency-graph anyway? If yes, it'd be probably more efficient if I wait (since I don't really know the npm-dependency-graph). Thanks! |
I was interested in a context menu too so i spend some time to create a simple one using Sprotty UIExtension as well as the IContextMenuItemProvider and IContextMenuService api. If you are interested i adapted the implementation for the mindmap example here: BjBe82@c87eac0 |
Very interesting, thanks! Imho it would be great to have a generic, Theia-independent implementation like yours in Sprotty for standalone deployments of Sprotty. @spoenemann What do you think? @BjBe82 Would you be interested in opening a PR where you put your context menu implementation (UI extension and ContextMenuService implementation) into an optional module in Sprotty and just use it in the mind-map example? The context menu provider should remain in the mindmap example. Thanks for letting us know! |
I'm not sure how useful it is in a stand-alone scenario. IMO a context menu is something for complex applications such as IDEs. "Normal" websites do not have custom context menus. |
Into the bargain, the surrounding framework often provides context menus and we should try to use that one to not look to alien, e.g. VS Code and Theia Desktop use the native context menu. |
My intention was not to provide an extension of the sprotty api in that case because i agree with @spoenemann and @JanKoehnlein that advanced frameworks might provide a context menu implementation. But for a small prototype i was interested in the sprotty context menu api so i created my own quite simple rendering. Here i just tried to provide a very lightweight example which could be added to the sprotty default examples if you are interested. Not saying that the rendering part is good or bad .... just to show that there is sprotty api around context menus and the fact that you discussed a “simple” example in this topic. |
I'm fine with adding it to the mindmap example. |
Fixes #139