6
6
*/
7
7
8
8
import React , { useEffect , useCallback } from 'react' ;
9
+ import styled from 'styled-components' ;
9
10
import { i18n } from '@kbn/i18n' ;
10
11
import {
11
12
EuiFlyout ,
@@ -21,9 +22,9 @@ import {
21
22
EuiForm ,
22
23
EuiFormRow ,
23
24
EuiCode ,
24
- EuiCodeEditor ,
25
25
EuiLink ,
26
26
EuiPanel ,
27
+ EuiTextColor ,
27
28
} from '@elastic/eui' ;
28
29
import { FormattedMessage } from '@kbn/i18n/react' ;
29
30
import { EuiText } from '@elastic/eui' ;
@@ -39,13 +40,29 @@ import {
39
40
sendPutOutput ,
40
41
} from '../../hooks' ;
41
42
import { isDiffPathProtocol , normalizeHostsForAgents } from '../../../common' ;
43
+ import { CodeEditor } from '../../../../../../src/plugins/kibana_react/public' ;
42
44
43
45
import { SettingsConfirmModal } from './confirm_modal' ;
44
46
import type { SettingsConfirmModalProps } from './confirm_modal' ;
45
47
import { HostsInput } from './hosts_input' ;
46
48
47
- import 'brace/mode/yaml' ;
48
- import 'brace/theme/textmate' ;
49
+ const CodeEditorContainer = styled . div `
50
+ min-height: 0;
51
+ position: relative;
52
+ height: 250px;
53
+ ` ;
54
+
55
+ const CodeEditorPlaceholder = styled ( EuiTextColor ) . attrs ( ( props ) => ( {
56
+ color : 'subdued' ,
57
+ size : 'xs' ,
58
+ } ) ) `
59
+ position: absolute;
60
+ top: 0;
61
+ right: 0;
62
+ // Matches monaco editor
63
+ font-family: Menlo, Monaco, 'Courier New', monospace;
64
+ pointer-events: none;
65
+ ` ;
49
66
50
67
const URL_REGEX = / ^ ( h t t p s ? ) : \/ \/ [ ^ \s $ . ? # ] .[ ^ \s ] * $ / gm;
51
68
@@ -361,21 +378,40 @@ export const SettingFlyout: React.FunctionComponent<Props> = ({ onClose }) => {
361
378
} ) }
362
379
fullWidth
363
380
>
364
- < EuiCodeEditor
365
- width = "100%"
366
- mode = "yaml"
367
- theme = "textmate"
368
- placeholder = "# YAML settings here will be added to the Elasticsearch output section of each policy"
369
- setOptions = { {
370
- minLines : 10 ,
371
- maxLines : 30 ,
372
- tabSize : 2 ,
373
- showGutter : false ,
374
- showPrintMargin : false ,
375
- } }
376
- { ...inputs . additionalYamlConfig . props }
377
- onChange = { inputs . additionalYamlConfig . setValue }
378
- />
381
+ < CodeEditorContainer >
382
+ < CodeEditor
383
+ languageId = "yaml"
384
+ width = "100%"
385
+ height = "250px"
386
+ value = { inputs . additionalYamlConfig . value }
387
+ onChange = { inputs . additionalYamlConfig . setValue }
388
+ options = { {
389
+ minimap : {
390
+ enabled : false ,
391
+ } ,
392
+
393
+ ariaLabel : i18n . translate ( 'xpack.fleet.settings.yamlCodeEditor' , {
394
+ defaultMessage : 'YAML Code Editor' ,
395
+ } ) ,
396
+ scrollBeyondLastLine : false ,
397
+ wordWrap : 'on' ,
398
+ wrappingIndent : 'indent' ,
399
+ automaticLayout : true ,
400
+ tabSize : 2 ,
401
+ // To avoid left margin
402
+ lineNumbers : 'off' ,
403
+ lineNumbersMinChars : 0 ,
404
+ glyphMargin : false ,
405
+ folding : false ,
406
+ lineDecorationsWidth : 0 ,
407
+ } }
408
+ />
409
+ { ( ! inputs . additionalYamlConfig . value || inputs . additionalYamlConfig . value === '' ) && (
410
+ < CodeEditorPlaceholder >
411
+ { `# YAML settings here will be added to the Elasticsearch output section of each policy` }
412
+ </ CodeEditorPlaceholder >
413
+ ) }
414
+ </ CodeEditorContainer >
379
415
</ EuiFormRow >
380
416
</ EuiPanel >
381
417
</ EuiForm >
0 commit comments