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

feat: upgrade react-markdown #681

Merged
merged 3 commits into from
May 13, 2021
Merged

Conversation

bryans99
Copy link
Collaborator

upgrade required for the following reasons

  1. dependabot reported a security issue with a package (trim) the older version of react-markdown was using. Note that the trim packages is still referenced by eslint tooling. This will be dealt with in a separate PR.
  2. dependency on path-browserify and process-browser can be removed.

The replacement was not straight forward as the mechanism for providing alternative rendering of components significantly changed. The Markdown component was refactored into its own component as react-markdown was being used in two places. It turns out that this was not necessary as the 2nd usage needs to use the raw react-markdown component at least for. The refactor was kept as it is possible the markdown component may be useful elsewhere. The original implementation had a dependency on specKey which has now been removed.

In addition the following changes have been done:

  1. Links to looker documentation in an extension now supported.
  2. List components render correctly.
  3. Links that have markup from search now work.

upgrade required for the following reasons
1. dependabot reported a security issue with a package (trim) the older version of react-markdown was using. Note that the trim packages is still referenced by eslint tooling. This will be dealt with in a separate PR.
2. dependency on path-browserify and process-browser can be removed.

The replacement was not straight forward as the mechanism for providing alternative rendering of components significantly changed. The Markdown component was refactored into its own component as react-markdown was being used in two places. It turns out that this was not necessary as the 2nd usage needs to use the raw react-markdown component at least for. The refactor was kept as it is possible the markdown component may be useful elsewhere. The original implementation had a dependency on specKey which has now been removed.

In addition the following changes have been done:
1. Links to looker documentation in an extension now supported.
2. List components render correctly.
3. Links that have markup from search now work.
@github-actions
Copy link
Contributor

APIX Tests

    1 files    72 suites   2m 54s ⏱️
268 tests 256 ✔️ 12 💤 0 ❌
287 runs  275 ✔️ 12 💤 0 ❌

Results for commit 654552f.

const handleClick = (e: BaseSyntheticEvent) => {
e.preventDefault()
if (linkClickHandler) {
// Could be a <mark> tag wrapped by an anchor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this new file a lot.

Similar to how anchors have a special case,
code blobs have a currently uncaught special case. It looks like your change makes this easier to address:
image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I think this file belongs in code-editor rather than here, so we can reuse it outside of APIX. I also hope to convert triple tick code blocks to use code display

Copy link
Contributor

@josephaxisa josephaxisa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that highlighting is not working as expected everywhere:

image

@bryans99
Copy link
Collaborator Author

@josephaxisa - that's not an issue introduced by my change. Also happens in the current marketplace version. Suspect it's going to be tricky to solve as I think code is similar to pre in that it ignores child elements. Create a separate issue is my recommendation.

Marketplace APIX version below

image

@github-actions
Copy link
Contributor

APIX Tests

    1 files    72 suites   2m 8s ⏱️
268 tests 256 ✔️ 12 💤 0 ❌
287 runs  275 ✔️ 12 💤 0 ❌

Results for commit f8df883.

@josephaxisa josephaxisa self-requested a review May 13, 2021 18:42
josephaxisa
josephaxisa previously approved these changes May 13, 2021
Copy link
Contributor

@josephaxisa josephaxisa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caught up about this in person. Issues mentioned above are better suited for another PR. This lgtm. Thanks Bryn!

@github-actions
Copy link
Contributor

APIX Tests

    1 files    72 suites   2m 33s ⏱️
268 tests 256 ✔️ 12 💤 0 ❌
287 runs  275 ✔️ 12 💤 0 ❌

Results for commit ccb02e3.

Copy link
Contributor

@jkaster jkaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great improvement. Very minor nit on a code comment, but LGTM.

@@ -70,8 +52,9 @@ export const remapHashURL = (specKey: string, url: string) =>
/**
* Clean urls from mark tags and remap tag/method hashbang urls to match the MethodScene route
* @param specKey A string to identify the spec in the URL
* @param url
* @param url - url
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this comment mean?

import { renderWithSearch } from '../../test-utils'
import { Markdown } from './Markdown'

describe('Markdown', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh. Tests!

const handleClick = (e: BaseSyntheticEvent) => {
e.preventDefault()
if (linkClickHandler) {
// Could be a <mark> tag wrapped by an anchor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I think this file belongs in code-editor rather than here, so we can reuse it outside of APIX. I also hope to convert triple tick code blocks to use code display

@bryans99 bryans99 merged commit 952ed30 into main May 13, 2021
@bryans99 bryans99 deleted the brynryans/upgrade-react-markdown branch May 13, 2021 22:28
@github-actions

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants