eui icon indicating copy to clipboard operation
eui copied to clipboard

feat: [EuiMarkdownFormat]: Added Option/Props to Open Link in New Tab

Open hsk11 opened this issue 1 year ago • 2 comments

Summary

Resolved #7919

We are Unable to Directly Config EuiMarkdownFormat to Open Link in Net Tab, which is essentially needed. Issue #7919

hsk11 avatar Aug 27 '24 16:08 hsk11

💚 CLA has been signed

@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>

cee-chen avatar Aug 28 '24 22:08 cee-chen

:green_heart: Build Succeeded

History

  • :broken_heart: Build #2648 failed 39774fc48a85a1688542a602432bbb7ec2e67613
  • :broken_heart: Build #2644 failed 170eda65582a139771682355632fb45e66a6308d

elasticmachine avatar Aug 28 '24 22:08 elasticmachine

@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 .

hsk11 avatar Aug 29 '24 19:08 hsk11