-
Notifications
You must be signed in to change notification settings - Fork 15
feat: html blocks! #875
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
Merged
Merged
feat: html blocks! #875
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3ca6ecc
setting html DANGEROUSLY
jennspencer e447442
UX fixes
jennspencer ec7af0d
updates
jennspencer 175589e
tests & tests & tests
jennspencer 88055d7
ugh
jennspencer af85883
Update __tests__/browser/markdown.test.js
jennspencer 433e733
Merge branch 'beta' into jenn/rm-9019-convert-html-blocks-to-mdx
jennspencer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
UX fixes
- Loading branch information
commit e447442d5d232f4bb9ae4e079f08b570c78c5ba4
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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,71 @@ | ||
| --- | ||
| title: 'HTML Blocks' | ||
| --- | ||
|
|
||
| ## JSX (with no HTML attributes) | ||
|
|
||
| <HTMLBlock runScripts={true}> | ||
| <script>console.log(true, 0);</script> | ||
| <h3>Header 0</h3> | ||
| <p>Paragraph with <em>italics</em> and <strong>bold stuff</strong>.</p> | ||
| <div>I am actually a div!</div> | ||
| </HTMLBlock> | ||
|
|
||
|
|
||
| ## JSX | ||
|
|
||
| <HTMLBlock> | ||
| <script>console.log(true, 1);</script> | ||
| <h3>Header 1</h3> | ||
| <p>Paragraph with <em>italics</em> and <strong>bold stuff</strong>.</p> | ||
| <div style={{ paddingLeft: "20px", color: "blue" }}> | ||
| Behold, I am blue and indented! | ||
| </div> | ||
| </HTMLBlock> | ||
|
|
||
|
|
||
| ## HTML as a prop | ||
|
|
||
| <HTMLBlock children='<script>console.log(true, 2);</script><h3>Header 2</h3> | ||
| <p>Paragraph with <em>italics</em> and <strong>bold stuff</strong>.</p> | ||
| <div style="padding-left: 20px; color: blue">Behold, I am blue and indented!</div>' /> | ||
|
|
||
|
|
||
| ## HTML in template literal | ||
|
|
||
| <HTMLBlock> | ||
| {` | ||
| <script>console.log(true, 3);</script> | ||
| <h3>Header 3</h3> | ||
| <p>Paragraph with <em>italics</em> and <strong>bold stuff</strong>.</p> | ||
| <div style="padding-left: 20px; color: blue"> | ||
| Behold, I am blue and indented! | ||
| </div> | ||
| `} | ||
| </HTMLBlock> | ||
|
|
||
|
|
||
| ## JSX in safe mode | ||
|
|
||
| <HTMLBlock safeMode={true}> | ||
| <script>console.log(true, 4);</script> | ||
| <h3>Header 4</h3> | ||
| <p>Paragraph with <em>italics</em> and <strong>bold stuff</strong>.</p> | ||
| <div style={{ paddingLeft: "20px", color: "blue" }}> | ||
| Behold, I am blue and indented! | ||
| </div> | ||
| </HTMLBlock> | ||
|
|
||
|
|
||
| ## HTML in safe mode | ||
|
|
||
| <HTMLBlock safeMode={true}> | ||
| {` | ||
| <script>console.log(true, 5);</script> | ||
| <h3>Header 5</h3> | ||
| <p>Paragraph with <em>italics</em> and <strong>bold stuff</strong>.</p> | ||
| <div style="padding-left: 20px; color: blue"> | ||
| Behold, I am blue and indented! | ||
| </div> | ||
| `} | ||
| </HTMLBlock> |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,7 +1,22 @@ | ||
|
|
||
| ## Sanitizing `style` tags | ||
|
|
||
| <style> | ||
| * { | ||
| background-color: olive; | ||
| } | ||
| </style> | ||
|
|
||
|
|
||
| ## Sanitizing `style` attributes | ||
|
|
||
| <p style="background-color: salmon">fish content</p> | ||
|
|
||
|
|
||
| ## Sanitizing html blocks | ||
|
|
||
| <HTMLBlock> | ||
| <h2>Header</h2> | ||
| <p>hello there</p> | ||
| </HTMLBlock> | ||
| [block:html] | ||
| { | ||
| "html": "<style>* { border: 3px solid magenta; }</style>" | ||
| } | ||
| [/block] |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
safeModewas my silly attempt to make suggested edits safer. Suggested edits could be submitted by anonymous users. And it features a preview mode, so if the submitter wasn't an admin, we wouldn't render the HTML. 🤷🏼There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that was the usage for us sure, but i'm wondering about the 1000 or downloads a week of
@readme/markdown? is this new improved renderer going to be internal only or are we improving on the current one?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, we can figure out the final details in another PR since it's a bit out of scope for this one 😅