forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Console] Add a dev config for the editor migration (elastic#176520)
## Summary This PR adds a dev config to Console to enable a migration to the Monaco editor. The config value is `false` by default and can be changed by adding `console.dev.enableMonaco: true` to `kibana.dev.yml`. Also a new custom Monaco language is registered for Console in the package `kbn/monaco` and will be worked on behind the config flag iteratively in the next weeks. To not let the dev config get into 8.13 release, this PR will only be merged **after** 8.13 has been branched. After this PR is merged, the team will start re-implementing existing Console features in the new Monaco editor, see elastic#176723 and elastic#176926 --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
Showing
15 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export const CONSOLE_LANG_ID = 'console'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export { CONSOLE_LANG_ID } from './constants'; | ||
export { ConsoleLang } from './language'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { LangModuleType } from '../types'; | ||
import { CONSOLE_LANG_ID } from './constants'; | ||
import { monaco } from '../monaco_imports'; | ||
|
||
export const languageConfiguration: monaco.languages.LanguageConfiguration = {}; | ||
|
||
export const lexerRules: monaco.languages.IMonarchLanguage = { | ||
defaultToken: 'invalid', | ||
regex_method: /get|post|put|patch|delete/, | ||
regex_url: /.*$/, | ||
// C# style strings | ||
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/, | ||
ignoreCase: true, | ||
tokenizer: { | ||
root: [ | ||
// whitespace | ||
{ include: '@rule_whitespace' }, | ||
// start a multi-line comment | ||
{ include: '@rule_start_multi_comment' }, | ||
// a one-line comment | ||
[/\/\/.*$/, 'comment'], | ||
// method | ||
[/@regex_method/, 'keyword'], | ||
// url | ||
[/@regex_url/, 'identifier'], | ||
], | ||
rule_whitespace: [[/[ \t\r\n]+/, 'WHITESPACE']], | ||
rule_start_multi_comment: [[/\/\*/, 'comment', '@rule_multi_comment']], | ||
rule_multi_comment: [ | ||
// match everything on a single line inside the comment except for chars / and * | ||
[/[^\/*]+/, 'comment'], | ||
// start a nested comment by going 1 level down | ||
[/\/\*/, 'comment', '@push'], | ||
// match the closing of the comment and return 1 level up | ||
['\\*/', 'comment', '@pop'], | ||
// match individual chars inside a multi-line comment | ||
[/[\/*]/, 'comment'], | ||
], | ||
string: [ | ||
[/[^\\"]+/, 'string'], | ||
[/@escapes/, 'string.escape'], | ||
[/\\./, 'string.escape.invalid'], | ||
[/"/, { token: 'string.quote', bracket: '@close', next: '@pop' }], | ||
], | ||
}, | ||
}; | ||
|
||
export const ConsoleLang: LangModuleType = { | ||
ID: CONSOLE_LANG_ID, | ||
lexerRules, | ||
languageConfiguration, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/plugins/console/public/application/containers/editor/monaco/monaco_editor.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React, { FunctionComponent, useState } from 'react'; | ||
import { CodeEditor } from '@kbn/code-editor'; | ||
import { css } from '@emotion/react'; | ||
import { CONSOLE_LANG_ID } from '@kbn/monaco'; | ||
|
||
export const MonacoEditor: FunctionComponent = () => { | ||
const [value, setValue] = useState('GET /.kibana/_search'); | ||
return ( | ||
<div | ||
css={css` | ||
width: 100%; | ||
`} | ||
> | ||
<CodeEditor languageId={CONSOLE_LANG_ID} value={value} onChange={setValue} fullWidth={true} /> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters