diff --git a/src/plugins/kibana_react/public/code_editor/languages/index.ts b/src/plugins/kibana_react/public/code_editor/languages/index.ts
index ff7da1725fa7f..b797ea44d1f91 100644
--- a/src/plugins/kibana_react/public/code_editor/languages/index.ts
+++ b/src/plugins/kibana_react/public/code_editor/languages/index.ts
@@ -9,5 +9,6 @@
import { Lang as CssLang } from './css';
import { Lang as HandlebarsLang } from './handlebars';
import { Lang as MarkdownLang } from './markdown';
+import { Lang as YamlLang } from './yaml';
-export { CssLang, HandlebarsLang, MarkdownLang };
+export { CssLang, HandlebarsLang, MarkdownLang, YamlLang };
diff --git a/src/plugins/kibana_react/public/code_editor/languages/yaml/constants.ts b/src/plugins/kibana_react/public/code_editor/languages/yaml/constants.ts
new file mode 100644
index 0000000000000..71a34088a216b
--- /dev/null
+++ b/src/plugins/kibana_react/public/code_editor/languages/yaml/constants.ts
@@ -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 = 'yaml';
diff --git a/src/plugins/kibana_react/public/code_editor/languages/yaml/index.ts b/src/plugins/kibana_react/public/code_editor/languages/yaml/index.ts
new file mode 100644
index 0000000000000..f501de74debec
--- /dev/null
+++ b/src/plugins/kibana_react/public/code_editor/languages/yaml/index.ts
@@ -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.
+ */
+import { LangModuleType } from '@kbn/monaco';
+import { languageConfiguration, lexerRules } from './language';
+import { LANG } from './constants';
+
+export const Lang: LangModuleType = { ID: LANG, languageConfiguration, lexerRules };
diff --git a/src/plugins/kibana_react/public/code_editor/languages/yaml/language.ts b/src/plugins/kibana_react/public/code_editor/languages/yaml/language.ts
new file mode 100644
index 0000000000000..d17f284b28408
--- /dev/null
+++ b/src/plugins/kibana_react/public/code_editor/languages/yaml/language.ts
@@ -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.
+ */
+
+/* eslint-disable @kbn/eslint/module_migration */
+import { conf, language } from 'monaco-editor/esm/vs/basic-languages/yaml/yaml';
+
+export { conf as languageConfiguration, language as lexerRules };
diff --git a/src/plugins/kibana_react/public/code_editor/register_languages.ts b/src/plugins/kibana_react/public/code_editor/register_languages.ts
index b4a0f4d53cdf4..a32318a7e4b20 100644
--- a/src/plugins/kibana_react/public/code_editor/register_languages.ts
+++ b/src/plugins/kibana_react/public/code_editor/register_languages.ts
@@ -6,8 +6,9 @@
* Side Public License, v 1.
*/
import { registerLanguage } from '@kbn/monaco';
-import { CssLang, HandlebarsLang, MarkdownLang } from './languages';
+import { CssLang, HandlebarsLang, MarkdownLang, YamlLang } from './languages';
registerLanguage(CssLang);
registerLanguage(HandlebarsLang);
registerLanguage(MarkdownLang);
+registerLanguage(YamlLang);
diff --git a/typings/index.d.ts b/typings/index.d.ts
index 2a5c5e3fa430f..85c001b26031b 100644
--- a/typings/index.d.ts
+++ b/typings/index.d.ts
@@ -37,3 +37,4 @@ declare module 'react-syntax-highlighter/dist/cjs/prism-light';
// Monaco languages support
declare module 'monaco-editor/esm/vs/basic-languages/markdown/markdown';
declare module 'monaco-editor/esm/vs/basic-languages/css/css';
+declare module 'monaco-editor/esm/vs/basic-languages/yaml/yaml';
diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/package_policy_input_var_field.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/package_policy_input_var_field.tsx
index eed94de97113d..398421278b723 100644
--- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/package_policy_input_var_field.tsx
+++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/components/package_policy_input_var_field.tsx
@@ -7,21 +7,20 @@
import React, { useState, memo, useMemo } from 'react';
import ReactMarkdown from 'react-markdown';
+import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import {
EuiFormRow,
EuiSwitch,
EuiFieldText,
EuiText,
- EuiCodeEditor,
- EuiTextArea,
EuiFieldPassword,
+ EuiCodeBlock,
} from '@elastic/eui';
import type { RegistryVarsEntry } from '../../../../types';
+import { CodeEditor } from '../../../../../../../../../../src/plugins/kibana_react/public';
-import 'brace/mode/yaml';
-import 'brace/theme/textmate';
import { MultiTextInput } from './multi_text_input';
export const PackagePolicyInputVarField: React.FunctionComponent<{
@@ -52,26 +51,34 @@ export const PackagePolicyInputVarField: React.FunctionComponent<{
switch (type) {
case 'yaml':
return frozen ? (
-
+
+ {value}
+
) : (
- onChange(newVal)}
- onBlur={() => setIsDirty(true)}
/>
);
case 'bool':
diff --git a/x-pack/plugins/fleet/public/components/settings_flyout/index.tsx b/x-pack/plugins/fleet/public/components/settings_flyout/index.tsx
index 9bc1bc977b786..3d3a4dda60632 100644
--- a/x-pack/plugins/fleet/public/components/settings_flyout/index.tsx
+++ b/x-pack/plugins/fleet/public/components/settings_flyout/index.tsx
@@ -6,6 +6,7 @@
*/
import React, { useEffect, useCallback } from 'react';
+import styled from 'styled-components';
import { i18n } from '@kbn/i18n';
import {
EuiFlyout,
@@ -21,9 +22,9 @@ import {
EuiForm,
EuiFormRow,
EuiCode,
- EuiCodeEditor,
EuiLink,
EuiPanel,
+ EuiTextColor,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiText } from '@elastic/eui';
@@ -39,13 +40,29 @@ import {
sendPutOutput,
} from '../../hooks';
import { isDiffPathProtocol, normalizeHostsForAgents } from '../../../common';
+import { CodeEditor } from '../../../../../../src/plugins/kibana_react/public';
import { SettingsConfirmModal } from './confirm_modal';
import type { SettingsConfirmModalProps } from './confirm_modal';
import { HostsInput } from './hosts_input';
-import 'brace/mode/yaml';
-import 'brace/theme/textmate';
+const CodeEditorContainer = styled.div`
+ min-height: 0;
+ position: relative;
+ height: 250px;
+`;
+
+const CodeEditorPlaceholder = styled(EuiTextColor).attrs((props) => ({
+ color: 'subdued',
+ size: 'xs',
+}))`
+ position: absolute;
+ top: 0;
+ right: 0;
+ // Matches monaco editor
+ font-family: Menlo, Monaco, 'Courier New', monospace;
+ pointer-events: none;
+`;
const URL_REGEX = /^(https?):\/\/[^\s$.?#].[^\s]*$/gm;
@@ -361,21 +378,40 @@ export const SettingFlyout: React.FunctionComponent = ({ onClose }) => {
})}
fullWidth
>
-
+
+
+ {(!inputs.additionalYamlConfig.value || inputs.additionalYamlConfig.value === '') && (
+
+ {`# YAML settings here will be added to the Elasticsearch output section of each policy`}
+
+ )}
+