eclipse-glsp / glsp

Graphical language server platform for building web-based diagram editors
https://www.eclipse.dev/glsp
Other
200 stars 32 forks source link

Context Menu for VSCode integration #414

Open tortmayr opened 3 years ago

tortmayr commented 3 years ago

Currently it's not possible to contribute to the context menu of a custom editor. In fact, the context menu for webviews is completely disabled. As a workaround the GLSP Diagram Menu has been contributed to the "editor menu" in https://github.com/eclipse-glsp/glsp-vscode-integration/pull/15.

There is an open issue for this https://github.com/microsoft/vscode/issues/54285. However, this issue is open since 2018 and has not been tackled yet. It's unlikley that it will be resolved soon. If we really need a context menu we'd have to implement a custom solution.

@lforst already has provided MVP for a context menu implementation that could be reused here: https://github.com/lforst/glsp-vscode-integration/tree/lforst/context-menu

tortmayr commented 2 years ago

Generic context menu support in webviews for VS Code is provided with this PR: https://github.com/microsoft/vscode/pull/154524 We should check wether this also works with custom editors once it's available as proposed API.

tortmayr commented 1 year ago

I have played around with the webview/context menu contribution point that was added in VS Code 1.72 to see whether this could be used to implement this feature. In theory this works but there are certain server limitations:

In general, it would be better to use a custom context menu implementation that lives in the webview. This would give access to all diagram related information and also enables dynamic menu items provided by the server. Regarding styling it could be aligned with the default vscode context menu (same size, css keys etc.) so that it integrates fluently with the rest of the IDE. (Optionally we could also provide a custom contribution point that allows declarative contributons via package.json) While this is significantly more effort than just integrating the webview/context endpoint it is probably the referred solution.

For now let's move this into the back log until we have a concrete use case and/or sponsor for this feature.