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(react): add support for rendering code blocks #29

Merged
merged 3 commits into from
Aug 18, 2021

Conversation

jpedroschmitz
Copy link
Contributor

This PR adds support for rendering code blocks.

Closes MAR-2137

@jpedroschmitz jpedroschmitz added the react-renderer Issues and PR's related to @graphcms/rich-text-react-renderer label Aug 16, 2021
@jpedroschmitz jpedroschmitz self-assigned this Aug 16, 2021
@linear
Copy link

linear bot commented Aug 16, 2021

MAR-2137 Add support for code-blocks on the React RTR

Code blocks are a new option that was introduced recently on the RT field.

AST example:

[
  {
    "type": "code-block",
    "children": [
      {
        "text": "const teste = 'teste'"
      }
    ]
  },
  {
    "type": "code-block",
    "children": [
      {
        "text": "const graph = 'cms'\n\n<?php $echo \"Hello\" ?>"
      }
    ]
  },
]

Props:

  • children

@changeset-bot
Copy link

changeset-bot bot commented Aug 16, 2021

🦋 Changeset detected

Latest commit: 97c24c6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@graphcms/rich-text-types Patch
@graphcms/rich-text-react-renderer Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Aug 16, 2021

size-limit report 📦

Path Size
packages/react-renderer/dist/rich-text-react-renderer.cjs.production.min.js 4.91 KB (+1.75% 🔺)
packages/react-renderer/dist/rich-text-react-renderer.esm.js 4.87 KB (+1.87% 🔺)
packages/types/dist/rich-text-types.cjs.production.min.js 51 B (0%)
packages/types/dist/rich-text-types.esm.js 64 B (0%)

@jpedroschmitz jpedroschmitz requested a review from notrab August 17, 2021 17:55
Copy link
Contributor

@notrab notrab left a comment

Choose a reason for hiding this comment

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

Looks good!

What's the difference between code-block and code_block. Which is the one I should be using, and which falls back to the correct one?

@jpedroschmitz
Copy link
Contributor Author

code-block is the type returned from the content AST.

code_block is the alias to create a custom renderer for it.

@jpedroschmitz jpedroschmitz merged commit 91495b9 into main Aug 18, 2021
@jpedroschmitz jpedroschmitz deleted the feat/code-blocks branch August 18, 2021 13:44
@github-actions github-actions bot mentioned this pull request Aug 18, 2021
@notrab
Copy link
Contributor

notrab commented Aug 18, 2021

@jpedroschmitz are we able to support both code_block and code-block for passing a custom renderer. That way it's a 1:1 mapping?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
react-renderer Issues and PR's related to @graphcms/rich-text-react-renderer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants