Skip to content

Commit

Permalink
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
Browse files Browse the repository at this point in the history
…-fix'
  • Loading branch information
kibanamachine committed Oct 18, 2022
1 parent b5dfab1 commit bb9ccf8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
17 changes: 12 additions & 5 deletions packages/shared-ux/markdown/impl/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
* Side Public License, v 1.
*/

import { EuiLink, EuiMarkdownEditor, EuiMarkdownEditorProps, EuiMarkdownFormat, getDefaultEuiMarkdownProcessingPlugins } from '@elastic/eui';
import {
EuiLink,
EuiMarkdownEditor,
EuiMarkdownEditorProps,
EuiMarkdownFormat,
getDefaultEuiMarkdownProcessingPlugins,
} from '@elastic/eui';
import React, { useState } from 'react';

export type MarkdownProps = Partial<
Expand Down Expand Up @@ -41,17 +47,18 @@ export const Markdown = ({

// openLinksInNewTab functionality from https://codesandbox.io/s/relaxed-yalow-hy69r4?file=/demo.js:482-645
const processingPlugins = getDefaultEuiMarkdownProcessingPlugins();
processingPlugins[1][1].components.a = (props) => (
<EuiLink {...props} target="_blank" />
);
processingPlugins[1][1].components.a = (props) => <EuiLink {...props} target="_blank" />;

// Render EuiMarkdownFormat when readOnly set to true
if (readOnly) {
if (!children && !markdownContent) {
throw new Error('Markdown content is required in [readOnly] mode');
}
return (
<EuiMarkdownFormat aria-label={ariaLabelContent ?? 'markdown component'} processingPluginList={openLinksInNewTab ? processingPlugins : undefined}>
<EuiMarkdownFormat
aria-label={ariaLabelContent ?? 'markdown component'}
processingPluginList={openLinksInNewTab ? processingPlugins : undefined}
>
{children ?? markdownContent!}
</EuiMarkdownFormat>
);
Expand Down
6 changes: 4 additions & 2 deletions packages/shared-ux/markdown/impl/markdown_format.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ export const MarkdownStoryComponent = (params: MarkdownStorybookParams) => {
<EuiFlexGroup>
<EuiFlexItem>
<Markdown
{...params}
{...params}
readOnly={true}
markdownContent={'My content in **markdown** format set as the *markdownContent prop*'}
/>
<Markdown {...params} readOnly={true}>
{'My content in **markdown** format passed as *children* [test link to open in new tab or not](https://www.elastic.co)'}
{
'My content in **markdown** format passed as *children* [test link to open in new tab or not](https://www.elastic.co)'
}
</Markdown>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
7 changes: 6 additions & 1 deletion packages/shared-ux/markdown/mocks/storybook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import type { MarkdownProps } from '@kbn/shared-ux-markdown-types';

type PropArguments = Pick<
MarkdownProps,
'readOnly' | 'placeholder' | 'markdownContent' | 'height' | 'ariaLabelContent' | 'openLinksInNewTab'
| 'readOnly'
| 'placeholder'
| 'markdownContent'
| 'height'
| 'ariaLabelContent'
| 'openLinksInNewTab'
>;

export type Params = Record<keyof PropArguments, any>;
Expand Down

0 comments on commit bb9ccf8

Please sign in to comment.