-
Notifications
You must be signed in to change notification settings - Fork 841
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EuiMarkdownEditor] Better support to extend to full height (#4245)
* Better support extend the md editor to full height * Adding previewClassName * Adding tests for previewClassName * CL number * Update src/components/markdown_editor/markdown_editor.tsx Co-authored-by: Caroline Horn <[email protected]> * Adding height prop full and resizing preview area based on textarea size. * Adding EuiResizeObserver. * Typo * Adding missing file from merge * Adding autoExpandPreview * Small fix * CL * Calculating toolbar and footer heights from their refs * Removed unused Sass file * Types * Small fixes * Account fully for markdown preview's border and margin when resizing to fit content * Update src/components/markdown_editor/markdown_editor.tsx Co-authored-by: Chandler Prall <[email protected]> * Removing unnecessary code * Respond to runtime changes in markdown footer height * Adding variable euiMarkdownEditorMinHeight * Improving snippets * Snippet Co-authored-by: Caroline Horn <[email protected]> Co-authored-by: Chandler Prall <[email protected]>
- Loading branch information
1 parent
3fa9c89
commit b0395e5
Showing
16 changed files
with
1,447 additions
and
154 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
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
111 changes: 111 additions & 0 deletions
111
src-docs/src/views/markdown_editor/markdown_editor_height.js
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,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 ( | ||
<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} | ||
/> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.