-
Notifications
You must be signed in to change notification settings - Fork 8.5k
add monaco to kbn/ui-shared-deps and load required features for all uses #58075
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 monaco to kbn/ui-shared-deps and load required features for all uses #58075
Conversation
…itor-syntax-highlighting
| if (__monaco !== monaco) { | ||
| throw new Error('react-monaco-editor is using a different version of monaco'); | ||
| } |
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.
It seems the only reason to expose the monaco instance to handlers like editorDidMount() is so consumers can get access to the version of monaco being used by react-monaco-editor. In our case this version should always be the same as the version imported from @kbn/ui-shared-deps/monaco, so I updated this and the signature for these handlers to ensure we keep a single source of truth.
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.
Excellent, yeah this makes sense to me
…itor-syntax-highlighting
…itor-syntax-highlighting
poffdeluxe
left a comment
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.
Changes look good -- I think one thing we might have to check, however, is if there's any further work that needs to be done to get the jest tests all working. We tell jest to transform the monaco editor so the imports work correctly: https://github.com/elastic/kibana/blob/master/src/dev/jest/config.js#L90
Jest should still work because the import of |
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
|
Pinging @elastic/kibana-operations (Team:Operations) |
lukasolson
left a comment
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.
AppArch code changes LGTM
| }); | ||
|
|
||
| // Register the theme | ||
| monaco.editor.defineTheme('euiColors', this.props.useDarkTheme ? DARK_THEME : LIGHT_THEME); |
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.
Should this be set on the default package? Or do we still want to leave it up to the implementation to import the colors?
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.
Not a blocker to this PR since this is the current implementation.
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.
We should avoid putting any code into the @kbn/ui-shared-deps that isn't directly from npm as that module is only built on bootstrap. So I'm going to say we should leave it here.
…ses (elastic#58075) * add monaco to kbn/ui-shared-deps and load required features for all uses * forgot to save a change * remove unused imports * include a cache buster to counteract issue elastic#58077 * include monaco.ts in ts project
… all uses (#58075) (#58167) * add monaco to kbn/ui-shared-deps and load required features for all uses (#58075) * add monaco to kbn/ui-shared-deps and load required features for all uses * forgot to save a change * remove unused imports * include a cache buster to counteract issue #58077 * include monaco.ts in ts project * update yarn.lock
|
7.x/7.7: 23e3ce7 |
…-out-of-legacy * 'master' of github.com:elastic/kibana: (109 commits) document difference between log record formats (elastic#57798) Expose elasticsearch config schema (elastic#57655) [ui/agg_response/tabify] update types for search/expressions/build_tabular_inspector_data.ts (elastic#58130) [SIEM] Cleans Cypress tests code (elastic#58134) fix: 🐛 make dev server Storybook builds work again (elastic#58188) Prevent core savedObjects plugin from being overridden (elastic#58193) Expose serverBasePath on client-side (elastic#58070) Fix legend sizing on area charts (elastic#58083) Drilldown plugin (elastic#58097) [skip-ci] Fix broken links to saved objects APIs in MIGRATION.md (elastic#58033) [ML] New Platform server shim: update datafeed routes (elastic#57739) Add flag for building static storybook site (elastic#58050) add monaco to kbn/ui-shared-deps and load required features for all uses (elastic#58075) [SIEM] Let us try out code owners for a little while and see what happens Add throttle param to Alerting readme (elastic#57609) [NP] Move ui/saved_objects to NP (elastic#57452) [Logs UI] Fix column reordering in settings page (elastic#58104) Fix browser date format (elastic#57714) Add filter for ILM phase to Index Management (revert elastic#45486) (elastic#57402) Clarify Precision function in Timelion Kibana (elastic#58031) ... # Conflicts: # x-pack/.i18nrc.json
|
Hey @spalger this is how it looks in the Timelion editor: canvas: I did |
|
Fixed the bug you mentioned in #58520, thanks! |


Once we merged the
@kbn/optimizerwe broke the syntax highlighting in canvas because the monaco editor is a stateful module that we weren't sharing via@kbn/ui-shared-deps. This moves it into the shared deps package so that all bundles/plugins can use it and so that it is bundled once.To use the monaco editor code should now use:
This monaco instance is the one populated with features by
packages/kbn-ui-shared-deps/monaco.tsand is used everywhere. Themonaco-editor/esm/vs/editor/editor.apiis still enabled forreact-monaco-editorbut should not be used by applications.The interface of the
<CodeEditor />from kibana-react was also tweaked as to not expose the monaco editor instance to handlers. The argument should always be the same instance accessible via the import, so that is now asserted whenever possible and consumers that need access to the monaco instance should import it instead. (this change was primarily to deal withtypeof monacoinstances that made less sense now that we're standardized on themonacovsmonacoEditornaming everywhere)