mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Fix text settings to be honored in Canvas markdown elements (#179948)
The `style` could be set in the legacy React `<Markdown>` component, so this change imitates it in the new shared ux markdown as well.
This commit is contained in:
parent
c1d310bbc6
commit
43ecbcf5da
3 changed files with 15 additions and 0 deletions
|
@ -11,6 +11,7 @@ date: 2022-10-03
|
|||
|
||||
This markdown component uses the **EuiMarkdownEditor** and **EuiMarkdownFormat** managed by `@elastic/eui`. If `readOnly` is set to true, and `markdownContent` or `children` are set, then the component renders **EuiMarkdownFormat** text. Otherwise the component will render the **EuiMarkdownEditor**. The height of the component can be set, but in order the control the width of the component, you can place the `<Markdown />` component in another component.
|
||||
Markdown extends all the EuiMarkdownEditorProps except for the `editorId`, `uiPlugins`, and `MarkdownFormatProps`.
|
||||
Like the legacy React `<Markdown>` component, `style` can be set but will only be passed to **EuiMarkdownFormat**.
|
||||
|
||||
## Component Properties
|
||||
|
||||
|
|
|
@ -33,4 +33,16 @@ describe('shared ux markdown component', () => {
|
|||
render(<Markdown markdownContent={exampleMarkdownContent} />);
|
||||
expect(screen.getByTestId('euiMarkdownEditorToolbar')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders EuiMarkdownEditor without style passed', () => {
|
||||
render(<Markdown style={{ color: 'red' }} data-test-subj="editor" />);
|
||||
expect(screen.getByTestId('editor')).not.toHaveStyle({ color: 'red' });
|
||||
});
|
||||
|
||||
it('renders EuiMarkdownFormat with style passed', () => {
|
||||
render(
|
||||
<Markdown style={{ color: 'red' }} data-test-subj="format" markdownContent="test" readOnly />
|
||||
);
|
||||
expect(screen.getByTestId('format')).toHaveStyle({ color: 'red' });
|
||||
});
|
||||
});
|
||||
|
|
|
@ -93,6 +93,8 @@ export const Markdown = ({
|
|||
parsingPluginList={_parsingPlugins}
|
||||
processingPluginList={openLinksInNewTab ? processingPlugins : undefined}
|
||||
data-test-subj={restProps['data-test-subj']}
|
||||
// There was a trick to pass style as a part of props in the legacy React <Markdown> component
|
||||
style={restProps.style}
|
||||
>
|
||||
{children ?? markdownContent!}
|
||||
</EuiMarkdownFormat>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue