-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Console][Meta] Migration to Monaco #57435
Comments
Pinging @elastic/es-ui (Team:Elasticsearch UI) |
@jloleysens With Monaco already rolled out in several places it definitely makes sense to use it for Console as well - nothing worse than maintaining two libraries doing the same thing slightly different. |
We could possibly address this old issue with Ace with this migration #11961. Will have to test the behaviour on Monaco first of course. |
See #42029 for a list of functional requirements that must be met by Monaco. |
Here is an update to the proposed migration strategy since a lot of work has been done on In Console we will need to replace The most difficult work for this migration is to create our custom language definition for Console. The package Documentation for custom language support in Monaco can be found here and some examples here. Since we will be writing our custom language definition for Console from scratch for Monaco, we can use this chance to switch from REST API specs to Elasticsearch specification repo as the source for generating autocomplete suggestions. |
There is an issue to possibly move custom language definitions out of |
Closing in favor of #180207 |
Goals
As part of this migration we want to achieve the following:
* Here, straightforward is taken to mean simple, not a small amount of work.
Components
Console consists of the following high-level components relevant to text editing and language services:
In the image above, the CoreEditor (1) uses the Lexer rules (2) to pick out different tokens that make up the Console language - indicated in red. This is done by looking at individual chars, collecting them into strings and attaching metadata to these strings. For instance the word
_search
would be associated with the token typeurl.part
. Lexing is a very fundamental component that other components build upon and is provided by (1) + (2). This also powers colors of different types (not listed above).The next component that builds on (1) is parsing (3) depicted in blue. Parsing looks at sequences of tokens and decides if the grammar and syntax is correct. Providing useful feedback to the user if it is incorrect via (1). The current implementation uses a JS script running inside of a WebWorker.
The next component in Console which also builds on (1) + (2) + (6) is the Sense Editor (4). The Sense Editor provides business logic used for reasoning about requests. For instance, in the image above if the cursor is on line 4 char 8, the Sense Editor can return metadata about the request like the start and end line (depicted in the upper green block).
The final component is Autocomplete (5). This also builds on (1) + (2) + (6) and provides the lower green block depicted in the image. Autocomplete knows how to traverse Console’s endpoint specifications to provide suggestions and snippet completion.
Proposed work
Per this issue (#30139) we know we want to replace Ace. Monaco is currently the best alternative (see FAQ below).
To get to the goals proposed above the outstanding work (ordered) is:
Take out Ace, drop in Monaco, this will break parsing
Make autocomplete work with Monaco
Make parsing work with Monaco
FAQ
What about mobile?
At the moment, Console's user interface is not optimised for mobile. Use of Monaco does preclude this possibility too - touch support has not yet been added.
Why not CodeMirror?
CodeMirror was suggested as an alternative editor here #30139. CodeMirror is smaller in size vs Monaco, however, we already know Monaco is being used inside of Kibana (like in Canvas and in a shared React component). This means we will only get the bundle size benefits if Kibana users manage to avoid Monaco in other places in Kibana.
There is also not a very good reason to duplicate functionality in our dependencies (2 x editor implementations) as this adds to the burden of maintenance, shared knowledge and shared code. Unless there is a particular reason to do so, we want to avoid this.
Currently CodeMirror is working on a major version upgrade (v6) that claims to address accessibility issues and provide a different (better?) programming API. CodeMirror can be re-evaluated when this release comes out, but at the moment there aren't any known good reasons to use it over Monaco. Please list them here if you can think of them!
The text was updated successfully, but these errors were encountered: