-
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.
Improve
CodeEditor
wrapper (#114500)
- Loading branch information
Showing
9 changed files
with
86 additions
and
54 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
10 changes: 7 additions & 3 deletions
10
...ver/public/application/components/source_viewer/__snapshots__/source_viewer.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
39 changes: 39 additions & 0 deletions
39
src/plugins/kibana_react/public/code_editor/code_editor_field.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,39 @@ | ||
/* | ||
* 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 from 'react'; | ||
import darkTheme from '@elastic/eui/dist/eui_theme_dark.json'; | ||
import lightTheme from '@elastic/eui/dist/eui_theme_light.json'; | ||
import { EuiFormControlLayout } from '@elastic/eui'; | ||
import { CodeEditor, Props } from './code_editor'; | ||
|
||
/** | ||
* Renders a Monaco code editor in the same style as other EUI form fields. | ||
*/ | ||
export const CodeEditorField: React.FunctionComponent<Props> = (props) => { | ||
const { width, height, options, fullWidth, useDarkTheme } = props; | ||
const theme = useDarkTheme ? darkTheme : lightTheme; | ||
const style = { | ||
width, | ||
height, | ||
backgroundColor: options?.readOnly | ||
? theme.euiFormBackgroundReadOnlyColor | ||
: theme.euiFormBackgroundColor, | ||
}; | ||
|
||
return ( | ||
<EuiFormControlLayout | ||
append={<div hidden />} | ||
style={style} | ||
readOnly={options?.readOnly} | ||
fullWidth={fullWidth} | ||
> | ||
<CodeEditor {...props} transparentBackground /> | ||
</EuiFormControlLayout> | ||
); | ||
}; |
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
12 changes: 12 additions & 0 deletions
12
src/plugins/kibana_react/public/code_editor/languages/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,12 @@ | ||
/* | ||
* 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 { LANG as CssLang } from './css/constants'; | ||
export { LANG as MarkdownLang } from './markdown/constants'; | ||
export { LANG as YamlLang } from './yaml/constants'; | ||
export { LANG as HandlebarsLang } from './handlebars/constants'; |
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