diff --git a/CHANGELOG.md b/CHANGELOG.md
index 84ee5fd6d38..394ea12f22a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,6 @@
## [`master`](https://github.com/elastic/eui/tree/master)
-No public interface changes since `31.1.0`.
+- Added `'full'` option to the `height` prop of `EuiMarkdownEditor`. Added `autoExpandPreview` and `maxHeight` props to `EuiMarkdownEditor` ([#4245](https://github.com/elastic/eui/pull/4245))
## [`31.1.0`](https://github.com/elastic/eui/tree/v31.1.0)
diff --git a/src-docs/src/views/markdown_editor/mardown_editor_example.js b/src-docs/src/views/markdown_editor/mardown_editor_example.js
index 98b8cd40e47..e5a78549503 100644
--- a/src-docs/src/views/markdown_editor/mardown_editor_example.js
+++ b/src-docs/src/views/markdown_editor/mardown_editor_example.js
@@ -16,10 +16,52 @@ import { Link } from 'react-router-dom';
import MarkdownEditor from './markdown_editor';
const markdownEditorSource = require('!!raw-loader!./markdown_editor');
const markdownEditorHtml = renderToHtml(MarkdownEditor);
+const markdownEditorSnippet = ``;
import MarkdownEditorErrors from './markdown_editor_errors';
const markdownEditorErrorsSource = require('!!raw-loader!./markdown_editor_errors');
const markdownEditorErrorsHtml = renderToHtml(MarkdownEditorErrors);
+const markdownEditorErrorsSnippet = ``;
+
+import MarkdownEditorHeight from './markdown_editor_height';
+const markdownEditorHeightSource = require('!!raw-loader!./markdown_editor_height');
+const markdownEditorHeightHtml = renderToHtml(MarkdownEditorHeight);
+const markdownEditorHeightSnippet = [
+ `// Custom height with auto-expanding preview
+`,
+ `// Height set to full
+`,
+ `// Custom height with no auto-expanding preview
+`,
+ `// Custom height and custom max height
+`,
+];
export const MarkdownEditorExample = {
title: 'Markdown editor',
@@ -66,6 +108,7 @@ export const MarkdownEditorExample = {
props: {
EuiMarkdownEditor,
},
+ snippet: markdownEditorSnippet,
demo: ,
},
{
@@ -93,7 +136,47 @@ export const MarkdownEditorExample = {
props: {
EuiMarkdownEditor,
},
+ snippet: markdownEditorErrorsSnippet,
demo: ,
},
+ {
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: markdownEditorHeightSource,
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: markdownEditorHeightHtml,
+ },
+ ],
+ title: 'Controlling the height',
+ text: (
+ <>
+
+ The height prop allows you to control the height
+ of the EuiMarkdownEditor. You can set the{' '}
+ height in pixels or pass{' '}
+ "full" to allow the{' '}
+ EuiMarkdownEditor to fill the height of its
+ container. By default, the autoExpandPreview prop
+ is set to true. This means that the preview{' '}
+ height is automatically adjusted to fit all the
+ content and avoid a scrollbar.
+
+
+ You can also control the maxHeight of the{' '}
+ editor/preview area. This prop only works when the{' '}
+ height is not set to{' '}
+ "full".
+
+ >
+ ),
+ props: {
+ EuiMarkdownEditor,
+ },
+ snippet: markdownEditorHeightSnippet,
+ demo: ,
+ },
],
};
diff --git a/src-docs/src/views/markdown_editor/markdown_editor_height.js b/src-docs/src/views/markdown_editor/markdown_editor_height.js
new file mode 100644
index 00000000000..bc1eb43bc74
--- /dev/null
+++ b/src-docs/src/views/markdown_editor/markdown_editor_height.js
@@ -0,0 +1,111 @@
+import React, { useState } from 'react';
+
+import {
+ EuiMarkdownEditor,
+ EuiFlexGroup,
+ EuiFlexItem,
+ EuiSpacer,
+} from '../../../../src/components';
+
+const initialContent1 = `## 👋 Hello there!
+
+I'm a **EuiMarkdownEditor** with:
+
+- a \`height\` set to \`200\`
+- my parent container is a flex item
+
+
+### Things you should know
+
+When my content is very long 😅
+
+The preview height is automatically adjusted 😉
+
+To avoid a scrollbar 😌
+
+### That's why I look good 😍
+
+`;
+
+const initialContent2 = `## 👋 Hello again!
+
+I'm a **EuiMarkdownEditor** with:
+- a \`height\` set to \`"full"\`
+- my parent container is a flex item with a \`height\` set to \`600\`
+`;
+
+const initialContent3 = `## 👋 Hi!
+
+I'm a **EuiMarkdownEditor** with:
+- a \`height\` set to \`200\`
+- my parent container is a flex item.
+- the \`autoExpandPreview\` is set to \`false\`
+
+### Things you should know
+
+When the content grows the preview height is not automatically adjusted. Just because the \`autoExpandPreview\` is set to \`false\` 😉
+`;
+
+const initialContent4 = `## 👋 Hello again!
+
+I'm just a **EuiMarkdownEditor** with:
+- a \`height\` set to \`200\`
+- a \`maxHeight\` set to \`300\`
+`;
+
+export default () => {
+ const [value1, setValue1] = useState(initialContent1);
+ const [value2, setValue2] = useState(initialContent2);
+ const [value3, setValue3] = useState(initialContent3);
+ const [value4, setValue4] = useState(initialContent4);
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
diff --git a/src/components/markdown_editor/__snapshots__/markdown_editor.test.tsx.snap b/src/components/markdown_editor/__snapshots__/markdown_editor.test.tsx.snap
index 628c25a8f8d..253487a8172 100644
--- a/src/components/markdown_editor/__snapshots__/markdown_editor.test.tsx.snap
+++ b/src/components/markdown_editor/__snapshots__/markdown_editor.test.tsx.snap
@@ -176,7 +176,8 @@ exports[`EuiMarkdownEditor is rendered 1`] = `
+
+
+`;
+
+exports[`EuiMarkdownEditor props autoExpandPreview is rendered with false 1`] = `
+
+`;
+
+exports[`EuiMarkdownEditor props height is rendered in full mode 1`] = `
+
+`;
+
+exports[`EuiMarkdownEditor props height is rendered with a custom size 1`] = `
+
+`;
+
+exports[`EuiMarkdownEditor props maxHeight is rendered with a custom size 1`] = `
+