-
Notifications
You must be signed in to change notification settings - Fork 840
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EuiMarkdownFormat/Editor] Allow configuring default plugins (#7985)
Co-authored-by: Cee Chen <[email protected]>
- Loading branch information
Showing
12 changed files
with
434 additions
and
114 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- Updated `getDefaultEuiMarkdownPlugins` to support the following new default plugin configurations: | ||
- `parsingConfig.linkValidator`, which allows configuring `allowRelative` and `allowProtocols` | ||
- `parsingConfig.emoji`, which allows configuring emoticon parsing | ||
- `processingConfig.linkProps`, which allows configuring rendered links with any props that `EuiLink` accepts | ||
- See our **Markdown plugins** documentation for example `EuiMarkdownFormat` and `EuiMarkdownEditor` usage |
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
37 changes: 0 additions & 37 deletions
37
packages/eui/src-docs/src/views/markdown_editor/markdown_link_validation.js
This file was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
packages/eui/src-docs/src/views/markdown_editor/markdown_plugin_config.tsx
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,37 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
EuiMarkdownFormat, | ||
getDefaultEuiMarkdownPlugins, | ||
} from '../../../../src'; | ||
|
||
export const markdownContent = ` | ||
- :cry: Automatic emoji formatting has been excluded from this markdown. | ||
- In the example below, only \`https:\` and \`mailto:\` protocols should turn into links. | ||
- Links should open in a new tab. | ||
https://elastic.co | ||
http://elastic.co | ||
[email protected] | ||
`; | ||
|
||
export default () => { | ||
const { processingPlugins, parsingPlugins } = getDefaultEuiMarkdownPlugins({ | ||
exclude: ['emoji'], | ||
processingConfig: { | ||
linkProps: { target: '_blank' }, | ||
}, | ||
parsingConfig: { | ||
linkValidator: { allowProtocols: ['https:', 'mailto:'] }, | ||
}, | ||
}); | ||
|
||
return ( | ||
<EuiMarkdownFormat | ||
processingPluginList={processingPlugins} | ||
parsingPluginList={parsingPlugins} | ||
> | ||
{markdownContent} | ||
</EuiMarkdownFormat> | ||
); | ||
}; |
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
27 changes: 27 additions & 0 deletions
27
packages/eui/src-docs/src/views/markdown_editor/markdown_plugin_props.tsx
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,27 @@ | ||
import { FunctionComponent } from 'react'; | ||
|
||
import type { | ||
ExcludableDefaultPlugins, | ||
DefaultParsingPluginsConfig as DefaultParsingPluginsConfigProps, | ||
DefaultProcessingPluginsConfig as DefaultProcessingPluginsConfigProps, | ||
} from '../../../../src/components/markdown_editor/plugins/markdown_default_plugins'; | ||
|
||
import type { EuiMarkdownLinkValidatorOptions as EuiMarkdownLinkValidatorOptionsProps } from '../../../../src/components/markdown_editor'; | ||
|
||
export const DefaultPluginsConfig: FunctionComponent<{ | ||
exclude?: ExcludableDefaultPlugins; | ||
parsingConfig?: DefaultParsingPluginsConfigProps; | ||
processingConfig?: DefaultProcessingPluginsConfigProps; | ||
}> = () => null; | ||
|
||
export const DefaultParsingPluginsConfig: FunctionComponent< | ||
DefaultParsingPluginsConfigProps | ||
> = () => null; | ||
|
||
export const DefaultProcessingPluginsConfig: FunctionComponent< | ||
DefaultProcessingPluginsConfigProps | ||
> = () => null; | ||
|
||
export const EuiMarkdownLinkValidatorOptions: FunctionComponent< | ||
EuiMarkdownLinkValidatorOptionsProps | ||
> = () => null; |
15 changes: 15 additions & 0 deletions
15
packages/eui/src/components/markdown_editor/__snapshots__/markdown_format.test.tsx.snap
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,15 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`EuiMarkdownFormat renders 1`] = ` | ||
<div | ||
aria-label="aria-label" | ||
class="euiText euiMarkdownFormat testClass1 testClass2 emotion-euiText-m-euiTextColor-default-euiMarkdownFormat-m-default-euiTestCss" | ||
data-test-subj="test subject string" | ||
> | ||
<p> | ||
<strong> | ||
Hello world | ||
</strong> | ||
</p> | ||
</div> | ||
`; |
Oops, something went wrong.