Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EuiMarkdownEditor] Better support to extend to full height #4245

Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fc4d869
Better support extend the md editor to full height
elizabetdev Nov 10, 2020
f4296b6
Adding previewClassName
elizabetdev Nov 10, 2020
944973e
Adding tests for previewClassName
elizabetdev Nov 10, 2020
6c8fb43
CL number
elizabetdev Nov 10, 2020
21c2b1a
Update src/components/markdown_editor/markdown_editor.tsx
elizabetdev Nov 10, 2020
a35a9e2
Adding height prop full and resizing preview area based on textarea …
elizabetdev Nov 12, 2020
c9c84f4
Adding EuiResizeObserver.
elizabetdev Nov 12, 2020
e079f94
Typo
elizabetdev Nov 12, 2020
ef36e25
Merge remote-tracking branch 'upstream/master' into EuiMarkdownEditor…
elizabetdev Nov 17, 2020
518b990
Adding missing file from merge
elizabetdev Nov 17, 2020
029296c
Adding autoExpandPreview
elizabetdev Nov 18, 2020
936cfbe
Small fix
elizabetdev Nov 18, 2020
553c375
Merge remote-tracking branch 'upstream/master' into EuiMarkdownEditor…
elizabetdev Nov 18, 2020
4aa4dbd
CL
elizabetdev Nov 18, 2020
1feb0f1
Calculating toolbar and footer heights from their refs
elizabetdev Nov 20, 2020
7f8574a
Removed unused Sass file
elizabetdev Nov 20, 2020
136acf9
Types
elizabetdev Nov 20, 2020
5b0b25d
Merge remote-tracking branch 'upstream/master' into EuiMarkdownEditor…
elizabetdev Nov 20, 2020
66381fe
Small fixes
elizabetdev Nov 20, 2020
fab3bfe
Merge branch 'master' into EuiMarkdownEditor-improving-height-props
chandlerprall Dec 10, 2020
d22e79f
Merge branch 'master' into EuiMarkdownEditor-improving-height-props
chandlerprall Dec 10, 2020
340be1c
Account fully for markdown preview's border and margin when resizing …
chandlerprall Dec 10, 2020
9d6f1d7
Update src/components/markdown_editor/markdown_editor.tsx
elizabetdev Dec 11, 2020
5b5e393
Removing unnecessary code
elizabetdev Dec 14, 2020
f10969d
Merge remote-tracking branch 'upstream/master' into EuiMarkdownEditor…
elizabetdev Jan 4, 2021
fc49243
Respond to runtime changes in markdown footer height
chandlerprall Jan 5, 2021
7736478
Adding variable euiMarkdownEditorMinHeight
elizabetdev Jan 7, 2021
82fce42
Merge remote-tracking branch 'upstream/master' into EuiMarkdownEditor…
elizabetdev Jan 7, 2021
dd7ca7b
Improving snippets
elizabetdev Jan 7, 2021
1e09b29
Snippet
elizabetdev Jan 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## [`master`](https://github.com/elastic/eui/tree/master)

No public interface changes since `30.4.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))

## [`30.4.0`](https://github.com/elastic/eui/tree/v30.4.0)

Expand Down
42 changes: 42 additions & 0 deletions src-docs/src/views/markdown_editor/mardown_editor_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ import MarkdownEditorErrors from './markdown_editor_errors';
const markdownEditorErrorsSource = require('!!raw-loader!./markdown_editor_errors');
const markdownEditorErrorsHtml = renderToHtml(MarkdownEditorErrors);

import MarkdownEditorHeight from './markdown_editor_height';
const markdownEditorHeightSource = require('!!raw-loader!./markdown_editor_height');
const markdownEditorHeightHtml = renderToHtml(MarkdownEditorHeight);

export const MarkdownEditorExample = {
title: 'Markdown editor',
beta: true,
Expand Down Expand Up @@ -95,5 +99,43 @@ export const MarkdownEditorExample = {
},
demo: <MarkdownEditorErrors />,
},
{
source: [
{
type: GuideSectionTypes.JS,
code: markdownEditorHeightSource,
},
{
type: GuideSectionTypes.HTML,
code: markdownEditorHeightHtml,
},
],
title: 'Controlling the height',
text: (
<>
<p>
The <EuiCode>height</EuiCode> prop allows you to control the height
of the <strong>EuiMarkdownEditor</strong>. You can set the{' '}
<EuiCode>height</EuiCode> in pixels or pass{' '}
<EuiCode>&quot;full&quot;</EuiCode> to allow the{' '}
<strong>EuiMarkdownEditor</strong> to fill the height of its
container. By default, the <EuiCode>autoExpandPreview</EuiCode> prop
is set to <EuiCode>true</EuiCode>. This means that the preview{' '}
<EuiCode>height</EuiCode> is automatically adjusted to fit all the
content and avoid a scrollbar.
</p>
<p>
You can also control the <EuiCode>maxHeight</EuiCode> of the{' '}
editor/preview area. This prop only works when the{' '}
<EuiCode>height</EuiCode> is not set to{' '}
<EuiCode>&quot;full&quot;</EuiCode>.
</p>
</>
),
props: {
EuiMarkdownEditor,
},
demo: <MarkdownEditorHeight />,
elizabetdev marked this conversation as resolved.
Show resolved Hide resolved
},
],
};
112 changes: 112 additions & 0 deletions src-docs/src/views/markdown_editor/markdown_editor_height.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
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 (
<div className="guideDemo__highlightGrid">
<EuiFlexGroup>
<EuiFlexItem>
<EuiMarkdownEditor
aria-label="EUI markdown editor demo"
initialViewMode="viewing"
value={value1}
onChange={setValue1}
height={200}
/>
</EuiFlexItem>
<EuiFlexItem style={{ height: '600px' }}>
<EuiMarkdownEditor
aria-label="EUI markdown editor demo"
initialViewMode="viewing"
value={value2}
onChange={setValue2}
height="full"
/>
</EuiFlexItem>
</EuiFlexGroup>

<EuiSpacer />

<EuiFlexGroup>
<EuiFlexItem>
<EuiMarkdownEditor
aria-label="EUI markdown editor demo"
initialViewMode="viewing"
value={value3}
onChange={setValue3}
height={200}
autoExpandPreview={false}
/>
</EuiFlexItem>
<EuiFlexItem>
<EuiMarkdownEditor
aria-label="EUI markdown editor demo"
initialViewMode="viewing"
value={value4}
onChange={setValue4}
height={200}
maxHeight={300}
autoExpandPreview={false}
/>
</EuiFlexItem>
</EuiFlexGroup>
</div>
);
};
Loading