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

[TSVB] Replaces EuiCodeEditor 👉 Monaco editor #100684

Merged
merged 27 commits into from
Jun 18, 2021

Conversation

Kuznietsov
Copy link
Contributor

@Kuznietsov Kuznietsov commented May 26, 2021

Closes: #99445.

In this PR:

  • EuiCodeEditor is replaced by Monaco editor in the 'vis_type_timeseries' plugin.

  • Added support of new languages (markdown, css, handlebars).

  • All languages are moved to kibana_react/code_editor. (from 'url_template_editor'), except though, which are defined at packages/kbn-monaco.

    Markdown editor

    Before:

    Markdown editor

    After:

    Monaco markdown editor

    Css/scss/less editor

    Before:

    Css editor

    After:

    Monaco css editor

@Kuznietsov Kuznietsov added WIP Work in progress auto-backport Deprecated - use backport:version if exact versions are needed labels May 26, 2021
@Kuznietsov Kuznietsov requested a review from alexwizp May 27, 2021 14:54
@Kuznietsov Kuznietsov removed the WIP Work in progress label May 28, 2021
@Kuznietsov Kuznietsov changed the title [WIP] [TSVB] Replace EuiCodeEditor 👉 Monaco editor [TSVB] Improves: replace EuiCodeEditor 👉 Monaco editor May 28, 2021
@alexwizp alexwizp requested a review from VladLasitsa June 1, 2021 08:20
@Kuznietsov Kuznietsov self-assigned this Jun 1, 2021
Copy link
Contributor

@VladLasitsa VladLasitsa left a comment

Choose a reason for hiding this comment

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

LGTM! Tested localy in chrome

@Kuznietsov Kuznietsov added Feature:TSVB TSVB (Time Series Visual Builder) v7.14.0 Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.0.0 labels Jun 2, 2021
@alexwizp
Copy link
Contributor

alexwizp commented Jun 8, 2021

Double check it on my local, works as expected

image

image

@timroes
Copy link
Contributor

timroes commented Jun 8, 2021

@elasticmachine run elasticsearch-ci/docs

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

I finally managed to make it work 😄
Kibana app code changes LGTM! I tested it locally and seems pretty cool 👏

@Kuznietsov
Copy link
Contributor Author

I finally managed to make it work 😄
Kibana app code changes LGTM! I tested it locally and seems pretty cool 👏

Thanks a lot)

@Kuznietsov
Copy link
Contributor Author

@elasticmachine merge upstream

@alexwizp
Copy link
Contributor

@elastic/kibana-app-services , @elastic/kibana-presentation please review

@Kuznietsov
Copy link
Contributor Author

@elasticmachine merge upstream

@Kuznietsov
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@poffdeluxe poffdeluxe left a comment

Choose a reason for hiding this comment

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

Changes LGTM!

My one concern is that we have languages living in multiple shared places now. It just makes it more difficult to figure out what languages we support in the kibana monaco code editor.

@Kuznietsov
Copy link
Contributor Author

@elasticmachine merge upstream

@alexwizp
Copy link
Contributor

@elastic/kibana-app-services please have a look, we are are waiting only your review

Copy link
Contributor

@jloleysens jloleysens left a comment

Choose a reason for hiding this comment

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

Great work @Kunzetsov ! App services changes look good to me (although I did not test the Handlebars editor in drilldown locally). Left a couple of comments.

import { ID } from './constants';
import { lexerRules } from './lexer_rules';

export const EsqlLang = { ID, lexerRules };
export const EsqlLang = { ID, lexerRules } as LangModuleType;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit; could we update this to:

Suggested change
export const EsqlLang = { ID, lexerRules } as LangModuleType;
export const EsqlLang: LangModuleType = { ID, lexerRules };

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, not a problem. I was using the style of @kbn/monaco )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -0,0 +1,12 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry if someone already asked this; what is the reason for having these language definitions live here and not in the @kbn/monaco package (with painless etc)?

Copy link
Contributor Author

@Kuznietsov Kuznietsov Jun 18, 2021

Choose a reason for hiding this comment

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

I'm not sure if it is a good idea to put some custom languages, required only in kibana plugins, to the core package. If the code owners will say, that it is a good idea, I'll do it)

Copy link
Contributor Author

@Kuznietsov Kuznietsov Jun 18, 2021

Choose a reason for hiding this comment

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

@jloleysens, what do you think about it? Is there any reasons for storing custom languages in the global package?

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, as far as I understand it, the languages defined in kbn/monaco are intended for use in plugins, or at least that plugins are the biggest consumers of that functionality. Could you help me understand the distinction with, for e.g., Handlebars vs Painless?

IMO it would be best to have a single place where languages are created and registered for easy reuse and discoverability - similar to @poffdeluxe comment.

Is part of the concern JS bundle size?

With the current kbn/monaco package plugins can't cherry-pick/declare languages they want to use and there is no good way to audit what languages are being used where (searching I suppose). But with monaco language definitions I don't think there is a lot of JS being loaded typically.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Painless, xjson and Esql are specific for elastic stack. But markdown, css and handlebars are common and they are just imported from monaco. I was thinking about that languages, which require syntax implementation, need to be located at kbn/monaco, all other - at plugins. But if somebody want to move languages, please, feel free to do it) I'm sorry, right now I'm working on the other task.

@Kuznietsov
Copy link
Contributor Author

Changes LGTM!

My one concern is that we have languages living in multiple shared places now. It just makes it more difficult to figure out what languages we support in the kibana monaco code editor.

I agree with you. But I'm not sure if somebody really need that languages, except some kibana plugins, which are using component of an editor from kibana_react.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
kibanaReact 367 378 +11
visTypeTimeseries 505 499 -6
total +5

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
kibanaReact 216 228 +12

Any counts in public APIs

Total count of every any typed public API. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats any for more detailed information.

id before after diff
kibanaReact 1 5 +4

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
kibanaReact 312.1KB 312.1KB -2.0B
visTypeTimeseries 1.7MB 986.0KB -796.0KB
total -796.0KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
kbnUiSharedDeps-elastic 2.6MB 2.6MB +1.0B
kbnUiSharedDeps-js 6.4MB 6.4MB -12.0B
kibanaReact 133.7KB 141.9KB +8.2KB
total +8.2KB
Unknown metric groups

API count

id before after diff
kibanaReact 245 257 +12

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @Kunzetsov

@Kuznietsov Kuznietsov merged commit a744483 into elastic:master Jun 18, 2021
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Jun 18, 2021
* Сhanged EuiCodeEditor to CodeEditor (monaco) at markdown_editor.js

* Added css lang support for monaco-editor.

* Added .d.ts for css lang import directly from monaco.

* Moved handlebars_url language to the code_editor.

Moved handlebars_url language registration to the code_editor.
Changed the way of registration of languages.

* Added merge for markdown_handlebars lang.

* Changed to simple markdown syntax.

Handlebars syntax breaks highlighting of special chars in markdown syntax.

* Removed useless mergeConfig function.

* Removed legacy import.

* Refactor export from monaco-editor.

* Fixed 'Could not find a declaration file for module'

* Fixed tests.

* Fixed typings errors.

* Added comment to typings.

* Fixed clearMarkdown for Monaco editor.

* Made changes based on suggestions.

* Fixed types errors.

* Fixed function tests types errors.

* Fixes, based on nits.

* Fixes based on nits.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@kibanamachine
Copy link
Contributor

💚 Backport successful

Status Branch Result
7.x

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Jun 18, 2021
* Сhanged EuiCodeEditor to CodeEditor (monaco) at markdown_editor.js

* Added css lang support for monaco-editor.

* Added .d.ts for css lang import directly from monaco.

* Moved handlebars_url language to the code_editor.

Moved handlebars_url language registration to the code_editor.
Changed the way of registration of languages.

* Added merge for markdown_handlebars lang.

* Changed to simple markdown syntax.

Handlebars syntax breaks highlighting of special chars in markdown syntax.

* Removed useless mergeConfig function.

* Removed legacy import.

* Refactor export from monaco-editor.

* Fixed 'Could not find a declaration file for module'

* Fixed tests.

* Fixed typings errors.

* Added comment to typings.

* Fixed clearMarkdown for Monaco editor.

* Made changes based on suggestions.

* Fixed types errors.

* Fixed function tests types errors.

* Fixes, based on nits.

* Fixes based on nits.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Yaroslav Kuznietsov <kuznetsov.yaroslav.yk@gmail.com>
@Kuznietsov Kuznietsov deleted the #99445 branch June 19, 2021 04:25
jloleysens added a commit to jloleysens/kibana that referenced this pull request Jun 21, 2021
…-png-pdf-report-type

* 'master' of github.com:elastic/kibana: (447 commits)
  skip flaky suite (elastic#102366)
  [Security Solution][Endpoint][Host Isolation] Isolation status badge from alert details (elastic#102274)
  Add email connector info for Elastic Cloud (elastic#91363)
  [Workplace Search] remove or replace xs props for text on source connect view (elastic#102663)
  Do not double register dashboard url generator (elastic#102599)
  [TSVB] Replaces EuiCodeEditor 👉 Monaco editor  (elastic#100684)
  [Discover] Update kibana.json adding owner and description (elastic#102292)
  [Exploratory View] Mobile experience (elastic#99565)
  chore(NA): moving @kbn/ui-shared-deps into bazel (elastic#101669)
  [TSVB] Index pattern select field disappear in Annotation tab (elastic#102314)
  [Security Solution][Endpoint][Host Isolation] Fixes bug where host isolation/unisolation works from alert details (elastic#102581)
  TSVB visualizations with no timefield do not render after upgrading from 7.12.1 to 7.13.0 (elastic#102494)
  [Logs UI] Add `event.original` fallback to message reconstruction rules (elastic#102236)
  [ML] Remove blank job definition as it is unused and out-of-sync with Elasticsearch (elastic#102506)
  [Lens] Fix wrong error detection on transition to Top values operation (elastic#102384)
  [ML] Anomaly detection job custom_settings improvements (elastic#102099)
  [Cases] Route: Get all alerts attach to a case (elastic#101878)
  Fixes wrong list exception type when creating endpoint event filters list (elastic#102522)
  remove search bar that's not working yet (elastic#102550)
  Migrated Ingest Node Pipeline Functional Tests to use test_user (elastic#102409)
  ...

# Conflicts:
#	x-pack/plugins/reporting/public/share_context_menu/register_pdf_png_reporting.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed Feature:TSVB TSVB (Time Series Visual Builder) release_note:enhancement Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.14.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[TSVB] Replace EuiCodeEditor 👉 Monaco editor
10 participants