[Monaco] Add JSON syntax support to the Monaco editor#143739
[Monaco] Add JSON syntax support to the Monaco editor#143739dokmic merged 5 commits intoelastic:mainfrom
Conversation
|
Pinging @elastic/kibana-app-services (Team:AppServicesUx) |
jloleysens
left a comment
There was a problem hiding this comment.
This is awesome! I'm approving, but it would be nice to test this out somewhere. Perhaps as a separate issue we can create a storybook of the monaco editor with our different languages.
f74990d to
e47d89e
Compare
|
Bumped the |
e47d89e to
589734f
Compare
589734f to
8679976
Compare
rshen91
left a comment
There was a problem hiding this comment.
These changes LGTM - can you add a story example for the kibana_react storybook? I'm thinking something like
add(
'json support',
() => (
<div>
<CodeEditor
languageId="json"
editorDidMount={(editor: monaco.editor.IStandaloneCodeEditor) => {
monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
validate: true,
schemas: [
{
uri: editor.getModel()?.uri.toString() ?? '',
fileMatch: ['*'],
schema: {
type: 'object',
properties: {
version: {
enum: ['v1', 'v2'],
},
},
},
},
],
});
}}
height={250}
value="{}"
onChange={action('onChange')}
/>
</div>
),
{
info: {
text: 'JSON language support',
},
})?
Thanks
8679976 to
7643c5a
Compare
dej611
left a comment
There was a problem hiding this comment.
@elastic/kibana-vis-editors checked Lens formula and works fine 👍
ee6e54d to
03c8754
Compare
ThomThomson
left a comment
There was a problem hiding this comment.
code editor changes LGTM! Code only review
03c8754 to
e25b197
Compare
e25b197 to
631d82f
Compare
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Async chunks
Page load bundle
Unknown metric groupsESLint disabled in files
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
* main: (43 commits) [Synthetics] Step details page screenshot (elastic#143452) [Lens] Datatable expression types improvement. (elastic#144173) [packages/kbn-journeys] start apm after browser start and stop after browser is closed (elastic#144267) [Files] Make files namespace agnostic (elastic#144019) Implement base browser-side logging system (elastic#144107) Correct wrong multiplier for byte conversion (elastic#143751) [Monaco] Add JSON syntax support to the Monaco editor (elastic#143739) CCS Smoke Test for Remote Clusters and Index Management (elastic#142423) [api-docs] Daily api_docs build (elastic#144294) chore(NA): include progress on Bazel tasks (elastic#144275) [RAM] Allow users to see event logs from all spaces they have access to (elastic#140449) [APM] Show recommended minimum size when going below 5 minutes (elastic#144170) [typecheck] delete temporary target_types dirs in packages (elastic#144271) [Security Solution][Endpoint] adds new alert loading utility and un-skip FTR test for endpoint (elastic#144133) [performance/journeys] revert data_stress_test_lens.ts journey step (elastic#144261) [TIP] Use search strategies in Threat Intelligence (elastic#143267) Optimize react-query dependencies (elastic#144206) [babel/node] invalidate cache when synth pkg map is updated (elastic#144258) [APM] AWS lambda estimated cost (elastic#143986) [Maps] layer group wizard (elastic#144129) ...
Fixes #146243 ## Summary Fixes Canvas expression autocomplete #143739 upgraded the monaco-editor dependency which uses a callback to the `onLanguage` method to initialize the expressions. The PR moved the `monaco.languages.register` command inside this callback and which was never triggered. Moving the `monaco.languages.register` command outside the callback appears to fix the issue.
Fixes elastic#146243 ## Summary Fixes Canvas expression autocomplete elastic#143739 upgraded the monaco-editor dependency which uses a callback to the `onLanguage` method to initialize the expressions. The PR moved the `monaco.languages.register` command inside this callback and which was never triggered. Moving the `monaco.languages.register` command outside the callback appears to fix the issue. (cherry picked from commit 19413b7)
…#146465) # Backport This will backport the following commits from `main` to `8.6`: - [[PresentationUtil] Fix Canvas expression autocomplete (#146425)](#146425) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Nick Peihl","email":"nick.peihl@elastic.co"},"sourceCommit":{"committedDate":"2022-11-28T19:30:37Z","message":"[PresentationUtil] Fix Canvas expression autocomplete (#146425)\n\nFixes #146243 \r\n\r\n## Summary\r\n\r\nFixes Canvas expression autocomplete\r\n\r\nhttps://github.com//pull/143739 upgraded the monaco-editor\r\ndependency which uses a callback to the `onLanguage` method to\r\ninitialize the expressions. The PR moved the `monaco.languages.register`\r\ncommand inside this callback and which was never triggered.\r\n\r\nMoving the `monaco.languages.register` command outside the callback\r\nappears to fix the issue.","sha":"19413b7daae983b95dbb9f5c7b39cb8f3578ebfa","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Presentation","release_note:skip","backport:prev-minor","v8.6.0","v8.7.0"],"number":146425,"url":"https://github.com/elastic/kibana/pull/146425","mergeCommit":{"message":"[PresentationUtil] Fix Canvas expression autocomplete (#146425)\n\nFixes #146243 \r\n\r\n## Summary\r\n\r\nFixes Canvas expression autocomplete\r\n\r\nhttps://github.com//pull/143739 upgraded the monaco-editor\r\ndependency which uses a callback to the `onLanguage` method to\r\ninitialize the expressions. The PR moved the `monaco.languages.register`\r\ncommand inside this callback and which was never triggered.\r\n\r\nMoving the `monaco.languages.register` command outside the callback\r\nappears to fix the issue.","sha":"19413b7daae983b95dbb9f5c7b39cb8f3578ebfa"}},"sourceBranch":"main","suggestedTargetBranches":["8.6"],"targetPullRequestStates":[{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/146425","number":146425,"mergeCommit":{"message":"[PresentationUtil] Fix Canvas expression autocomplete (#146425)\n\nFixes #146243 \r\n\r\n## Summary\r\n\r\nFixes Canvas expression autocomplete\r\n\r\nhttps://github.com//pull/143739 upgraded the monaco-editor\r\ndependency which uses a callback to the `onLanguage` method to\r\ninitialize the expressions. The PR moved the `monaco.languages.register`\r\ncommand inside this callback and which was never triggered.\r\n\r\nMoving the `monaco.languages.register` command outside the callback\r\nappears to fix the issue.","sha":"19413b7daae983b95dbb9f5c7b39cb8f3578ebfa"}}]}] BACKPORT--> Co-authored-by: Nick Peihl <nick.peihl@elastic.co>
Summary
Resolves #107733 and #138599.
The PR adds JSON syntax support to the monaco editor.
A custom schema can be defined per editor instance using the
editorDidMountlife-cycle hook in theCodeEditorcomponent.