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

[EuiMarkdownFormat/Editor] Allow configuring default plugins #7985

Merged
merged 8 commits into from
Aug 29, 2024

Conversation

hsk11
Copy link
Contributor

@hsk11 hsk11 commented Aug 27, 2024

Summary

closes #7919

This PR adds the ability to configure EUI's default parsing and processing plugins (on a limited basis for processing). Example usage:

const { parsingPlugins, processingPlugins } = getDefaultEuiMarkdownPlugins({
  // Exclude plugins as necessary
  exclude: ['emoji'],
  parsingConfig: {
    // Customize what link protocols are allowed
    linkValidator: { allowProtocols: ['https:', 'mailto:'] },
  },
  processingConfig: {
    // Configure all links to open in new tabs/windows
    linkProps: { target: '_blank' },
  },
});

// Pass the customized plugins to your markdown component
<EuiMarkdownFormat
  parsingPluginList={parsingPlugins}
  processingPluginList={processingPlugins}
/>

QA

Note that a majority of config regression QA testing should be handled by the new markdown_format.test.tsx file.

General checklist

  • Browser QA
    • Checked in Chrome, Safari, Edge, and Firefox
      - [ ] Checked in both light and dark modes
      - [ ] Checked in mobile
      - [ ] Checked for accessibility including keyboard-only and screenreader modes
  • Docs site QA
  • Code quality checklist
  • Release checklist
    • A changelog entry exists and is marked appropriately.
      - [ ] If applicable, added the breaking change issue label (and filled out the breaking change checklist)
  • Designer checklist - N/A

@hsk11 hsk11 requested a review from a team as a code owner August 27, 2024 16:58
Copy link

cla-checker-service bot commented Aug 27, 2024

💚 CLA has been signed

@hsk11 hsk11 changed the title feat: [EuiMarkdownFormat]: Added Opetion to Open Link in New Tab feat: [EuiMarkdownFormat]: Added Option/Props to Open Link in New Tab Aug 28, 2024
@cee-chen cee-chen self-requested a review August 28, 2024 15:04
@cee-chen cee-chen force-pushed the feat/EuiMarkdownFormat/openlinks-new-tab branch 2 times, most recently from 4967b1d to 336c751 Compare August 28, 2024 22:00
hsk11 and others added 8 commits August 28, 2024 15:05
… UI plugins

+ Add missing EuiMarkdownFormat unit tests
+ bogart test file for testing rendered output of `getDefaultEuiMarkdownPlugins`
- will allow passing `target: "_blank"` configs and more (e.g. rel, disabled, color, etc)
- replace link validation example with this one, since it's now a better way of configuring the linkValidator plugin

- add more defaults to props docs

- clean up sidebar links/headings for Markdown plugins page
@cee-chen cee-chen force-pushed the feat/EuiMarkdownFormat/openlinks-new-tab branch from 336c751 to 186393f Compare August 28, 2024 22:05
@cee-chen cee-chen changed the title feat: [EuiMarkdownFormat]: Added Option/Props to Open Link in New Tab [EuiMarkdownFormat/Editor] Allow configuring default plugins Aug 28, 2024
@cee-chen
Copy link
Member

cee-chen commented Aug 28, 2024

@hsk11, I took over and extended your PR to apply to the generic getDefaultEuiMarkdownPlugins() function, as that is generally the API in which we want consumers to interact with our markdown plugins, rather than the components directly (which should have higher component-level concerns instead). This also enables EuiMarkdownEditor to benefit from this configuration and not just EuiMarkdownFormat (since they both accept the same plugins props).

The following setup will result in the outcome #7919 asks for:

const { processingPlugins } = getDefaultEuiMarkdownPlugins({
  processingConfig: {
    linkProps: { target: '_blank' },
  },
});

<EuiMarkdownFormat processingPluginList={processingPlugins}>
  [Opens in new tab](https://elastic.co)
</EuiMarkdownFormat>

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

@cee-chen cee-chen merged commit 23bef2b into elastic:main Aug 29, 2024
5 checks passed
@hsk11
Copy link
Contributor Author

hsk11 commented Aug 29, 2024

@hsk11, I took over and extended your PR to apply to the generic getDefaultEuiMarkdownPlugins() function, as that is generally the API in which we want consumers to interact with our markdown plugins, rather than the components directly (which should have higher component-level concerns instead). This also enables EuiMarkdownEditor to benefit from this configuration and not just EuiMarkdownFormat (since they both accept the same plugins props).

The following setup will result in the outcome #7919 asks for:

const { processingPlugins } = getDefaultEuiMarkdownPlugins({
  processingConfig: {
    linkProps: { target: '_blank' },
  },
});

<EuiMarkdownFormat processingPluginList={processingPlugins}>
  [Opens in new tab](https://elastic.co)
</EuiMarkdownFormat>

Thanks, Even I thought of Directly Editing there But did not changed it Because Wanted to make Sure i wont Break the getDefaultEuiMarkdownPlugins(), as some people might be using it the way you implemented it now. IMO it would be great if we also just allow to set linkTraget just by passing the prop in EuiMarkDownFormat component .

jbudz pushed a commit to elastic/kibana that referenced this pull request Sep 10, 2024
`v95.9.0`⏩`v95.10.1`

> [!note]
> **EuiDataGrid**'s header cells have received a major UX change in
order to support interactive children within header content. Column
header actions now must be hovered and then clicked directly, or opened
with the Enter key, as opposed to being able to click the entire header
cell to see the actions popover.

_[Questions? Please see our Kibana upgrade
FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)_

---

## [`v95.10.0`](https://github.com/elastic/eui/releases/v95.10.0)

- Updated `EuiDataGrid` to support interactive header cell content
([#7898](elastic/eui#7898))
- Updated `EuiSearchBar`'s `field_value_selection` filter type with a
new `autoSortOptions` config, allowing consumers to configure whether or
not selected options are automatically sorted to the top of the filter
list ([#7958](elastic/eui#7958))
- Updated `getDefaultEuiMarkdownPlugins` to support the following new
default plugin configurations:
([#7985](elastic/eui#7985))
- `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
- Updated `EuiDatePicker` to support `append` and `prepend` nodes in its
form control layout ([#7987](elastic/eui#7987))

**Bug fixes**

- Fixed border rendering bug with inline `EuiDatePicker`s with
`shadow={false}` ([#7987](elastic/eui#7987))
- Fixed `EuiSuperSelect`'s placeholder text color to match other form
controls ([#7995](elastic/eui#7995))

**Accessibility**

- Improved the keyboard navigation and screen reader output for
`EuiDataGrid` header cells
([#7898](elastic/eui#7898))

## [`v95.10.1`](https://github.com/elastic/eui/releases/v95.10.1)

**Bug fixes**

- Fixed a visual bug in compact density `EuiDataGrid`s, where the header
cell height would increase when the actions button became visible
([#7999](elastic/eui#7999))

---------

Co-authored-by: Lene Gadewoll <lene.gadewoll@elastic.co>
gergoabraham pushed a commit to gergoabraham/kibana that referenced this pull request Sep 13, 2024
`v95.9.0`⏩`v95.10.1`

> [!note]
> **EuiDataGrid**'s header cells have received a major UX change in
order to support interactive children within header content. Column
header actions now must be hovered and then clicked directly, or opened
with the Enter key, as opposed to being able to click the entire header
cell to see the actions popover.

_[Questions? Please see our Kibana upgrade
FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)_

---

## [`v95.10.0`](https://github.com/elastic/eui/releases/v95.10.0)

- Updated `EuiDataGrid` to support interactive header cell content
([elastic#7898](elastic/eui#7898))
- Updated `EuiSearchBar`'s `field_value_selection` filter type with a
new `autoSortOptions` config, allowing consumers to configure whether or
not selected options are automatically sorted to the top of the filter
list ([elastic#7958](elastic/eui#7958))
- Updated `getDefaultEuiMarkdownPlugins` to support the following new
default plugin configurations:
([elastic#7985](elastic/eui#7985))
- `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
- Updated `EuiDatePicker` to support `append` and `prepend` nodes in its
form control layout ([elastic#7987](elastic/eui#7987))

**Bug fixes**

- Fixed border rendering bug with inline `EuiDatePicker`s with
`shadow={false}` ([elastic#7987](elastic/eui#7987))
- Fixed `EuiSuperSelect`'s placeholder text color to match other form
controls ([elastic#7995](elastic/eui#7995))

**Accessibility**

- Improved the keyboard navigation and screen reader output for
`EuiDataGrid` header cells
([elastic#7898](elastic/eui#7898))

## [`v95.10.1`](https://github.com/elastic/eui/releases/v95.10.1)

**Bug fixes**

- Fixed a visual bug in compact density `EuiDataGrid`s, where the header
cell height would increase when the actions button became visible
([elastic#7999](elastic/eui#7999))

---------

Co-authored-by: Lene Gadewoll <lene.gadewoll@elastic.co>
markov00 pushed a commit to markov00/kibana that referenced this pull request Sep 18, 2024
`v95.9.0`⏩`v95.10.1`

> [!note]
> **EuiDataGrid**'s header cells have received a major UX change in
order to support interactive children within header content. Column
header actions now must be hovered and then clicked directly, or opened
with the Enter key, as opposed to being able to click the entire header
cell to see the actions popover.

_[Questions? Please see our Kibana upgrade
FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)_

---

## [`v95.10.0`](https://github.com/elastic/eui/releases/v95.10.0)

- Updated `EuiDataGrid` to support interactive header cell content
([elastic#7898](elastic/eui#7898))
- Updated `EuiSearchBar`'s `field_value_selection` filter type with a
new `autoSortOptions` config, allowing consumers to configure whether or
not selected options are automatically sorted to the top of the filter
list ([elastic#7958](elastic/eui#7958))
- Updated `getDefaultEuiMarkdownPlugins` to support the following new
default plugin configurations:
([elastic#7985](elastic/eui#7985))
- `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
- Updated `EuiDatePicker` to support `append` and `prepend` nodes in its
form control layout ([elastic#7987](elastic/eui#7987))

**Bug fixes**

- Fixed border rendering bug with inline `EuiDatePicker`s with
`shadow={false}` ([elastic#7987](elastic/eui#7987))
- Fixed `EuiSuperSelect`'s placeholder text color to match other form
controls ([elastic#7995](elastic/eui#7995))

**Accessibility**

- Improved the keyboard navigation and screen reader output for
`EuiDataGrid` header cells
([elastic#7898](elastic/eui#7898))

## [`v95.10.1`](https://github.com/elastic/eui/releases/v95.10.1)

**Bug fixes**

- Fixed a visual bug in compact density `EuiDataGrid`s, where the header
cell height would increase when the actions button became visible
([elastic#7999](elastic/eui#7999))

---------

Co-authored-by: Lene Gadewoll <lene.gadewoll@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[EuiMarkdownFormat] : Allow links to open in a new tab!
3 participants