-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Vega] Replace EUICodeEditor with Monaco (#116041)
Closes: #106967 Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
82291dd
commit 266b842
Showing
11 changed files
with
216 additions
and
91 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
9 changes: 9 additions & 0 deletions
9
src/plugins/kibana_react/public/code_editor/languages/hjson/constants.ts
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 LANG = 'hjson'; |
13 changes: 13 additions & 0 deletions
13
src/plugins/kibana_react/public/code_editor/languages/hjson/index.ts
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,13 @@ | ||
/* | ||
* 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 '@kbn/monaco'; | ||
import { languageConfiguration, lexerRules } from './language'; | ||
import { LANG } from './constants'; | ||
|
||
export const Lang: LangModuleType = { ID: LANG, languageConfiguration, lexerRules }; |
90 changes: 90 additions & 0 deletions
90
src/plugins/kibana_react/public/code_editor/languages/hjson/language.ts
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,90 @@ | ||
/* | ||
* 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 { monaco } from '@kbn/monaco'; | ||
|
||
export const languageConfiguration: monaco.languages.LanguageConfiguration = { | ||
brackets: [ | ||
['{', '}'], | ||
['[', ']'], | ||
], | ||
autoClosingPairs: [ | ||
{ open: '{', close: '}' }, | ||
{ open: '[', close: ']' }, | ||
{ open: '"', close: '"', notIn: ['string'] }, | ||
], | ||
comments: { | ||
lineComment: '//', | ||
blockComment: ['/*', '*/'], | ||
}, | ||
}; | ||
|
||
export const lexerRules: monaco.languages.IMonarchLanguage = { | ||
defaultToken: '', | ||
tokenPostfix: '', | ||
escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/, | ||
digits: /-?(?:0|[1-9]\d*)(?:(?:\.\d+)?(?:[eE][+-]?\d+)?)?/, | ||
symbols: /[,:]+/, | ||
tokenizer: { | ||
root: [ | ||
[/(@digits)n?/, 'number'], | ||
[/(@symbols)n?/, 'delimiter'], | ||
|
||
{ include: '@keyword' }, | ||
{ include: '@url' }, | ||
{ include: '@whitespace' }, | ||
{ include: '@brackets' }, | ||
{ include: '@keyName' }, | ||
{ include: '@string' }, | ||
], | ||
|
||
keyword: [[/(?:true|false|null)\b/, 'keyword']], | ||
|
||
url: [ | ||
[ | ||
/(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})/, | ||
'string', | ||
], | ||
], | ||
|
||
keyName: [[/(?:[^,\{\[\}\]\s]+|"(?:[^"\\]|\\.)*")\s*(?=:)/, 'variable']], | ||
|
||
brackets: [[/{/, '@push'], [/}/, '@pop'], [/[[(]/], [/[\])]/]], | ||
|
||
whitespace: [ | ||
[/[ \t\r\n]+/, ''], | ||
[/\/\*/, 'comment', '@comment'], | ||
[/\/\/.*$/, 'comment'], | ||
], | ||
|
||
comment: [ | ||
[/[^\/*]+/, 'comment'], | ||
[/\*\//, 'comment', '@pop'], | ||
[/[\/*]/, 'comment'], | ||
], | ||
|
||
string: [ | ||
[/(?:[^,\{\[\}\]\s]+|"(?:[^"\\]|\\.)*")\s*/, 'string'], | ||
[/"""/, 'string', '@stringLiteral'], | ||
[/"/, 'string', '@stringDouble'], | ||
], | ||
|
||
stringDouble: [ | ||
[/[^\\"]+/, 'string'], | ||
[/@escapes/, 'string.escape'], | ||
[/\\./, 'string.escape.invalid'], | ||
[/"/, 'string', '@pop'], | ||
], | ||
|
||
stringLiteral: [ | ||
[/"""/, 'string', '@pop'], | ||
[/\\""""/, 'string', '@pop'], | ||
[/./, 'string'], | ||
], | ||
}, | ||
} as monaco.languages.IMonarchLanguage; |
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
20 changes: 15 additions & 5 deletions
20
src/plugins/vis_types/vega/public/components/vega_editor.scss
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
Oops, something went wrong.