-
Notifications
You must be signed in to change notification settings - Fork 545
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
ea1958c
commit d4276ba
Showing
62 changed files
with
5,708 additions
and
29 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Binary file added
BIN
+9.87 KB
...tionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.74 KB
...s/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-dimmed-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.1 KB
...nBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.87 KB
...s/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.87 KB
...tionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-dark-tritanopia-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.84 KB
...ionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-light-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10 KB
...Bar.test.ts-snapshots/drafts-ActionBar-CommentBox-light-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.84 KB
.../drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-light-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.84 KB
...ionBar.test.ts-snapshots/drafts-ActionBar-CommentBox-light-tritanopia-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-7.49 KB
...s/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-dark-colorblind-linux.png
Binary file not shown.
Binary file removed
BIN
-7.39 KB
...nents/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-dark-dimmed-linux.png
Binary file not shown.
Binary file removed
BIN
-7.55 KB
...rafts/ActionBar.test.ts-snapshots/drafts-ActionBar-dark-high-contrast-linux.png
Binary file not shown.
Binary file removed
BIN
-7.49 KB
...s/components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-dark-linux.png
Binary file not shown.
Binary file removed
BIN
-7.49 KB
...s/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-dark-tritanopia-linux.png
Binary file not shown.
Binary file removed
BIN
-7.54 KB
.../drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-light-colorblind-linux.png
Binary file not shown.
Binary file removed
BIN
-7.49 KB
...afts/ActionBar.test.ts-snapshots/drafts-ActionBar-light-high-contrast-linux.png
Binary file not shown.
Binary file removed
BIN
-7.54 KB
.../components/drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-light-linux.png
Binary file not shown.
Binary file removed
BIN
-7.54 KB
.../drafts/ActionBar.test.ts-snapshots/drafts-ActionBar-light-tritanopia-linux.png
Binary file not shown.
This file contains 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,157 @@ | ||
--- | ||
componentId: markdown_editor | ||
title: MarkdownEditor | ||
status: Deprecated | ||
description: Full-featured Markdown input. | ||
storybook: '/react/storybook?path=/story/components-forms-markdowneditor--default' | ||
--- | ||
|
||
import data from '../../../packages/react/src/drafts/MarkdownEditor/MarkdownEditor.docs.json' | ||
|
||
```js | ||
import {MarkdownEditor} from '@primer/react/drafts' | ||
``` | ||
|
||
`MarkdownEditor` is a full-featured editor for GitHub Flavored Markdown, with support for: | ||
|
||
- Formatting (keyboard shortcuts & toolbar buttons) | ||
- File uploads (drag & drop, paste, click to upload) | ||
- Inline suggestions (emojis, `@` mentions, and `#` references) | ||
- Saved replies | ||
- Markdown pasting (ie, paste URL onto selected text to create a link) | ||
- List editing (create a new list item on `Enter`) | ||
- Indenting selected text | ||
|
||
## Examples | ||
|
||
### Minimal Example | ||
|
||
A `Label` is always required for accessibility: | ||
|
||
```javascript live noinline drafts | ||
const renderMarkdown = async markdown => { | ||
// In production code, this would make a query to some external API endpoint to render | ||
return 'Rendered Markdown.' | ||
} | ||
|
||
const MinimalExample = () => { | ||
const [value, setValue] = React.useState('') | ||
|
||
return ( | ||
<MarkdownEditor value={value} onChange={setValue} onRenderPreview={renderMarkdown}> | ||
<MarkdownEditor.Label>Minimal Example</MarkdownEditor.Label> | ||
</MarkdownEditor> | ||
) | ||
} | ||
|
||
render(MinimalExample) | ||
``` | ||
|
||
### Suggestions, File Uploads, and Saved Replies | ||
|
||
```javascript live noinline drafts | ||
const renderMarkdown = async markdown => 'Rendered Markdown.' | ||
|
||
const uploadFile = async file => ({ | ||
url: `https://example.com/${encodeURIComponent(file.name)}`, | ||
file, | ||
}) | ||
|
||
const emojis = [ | ||
{name: '+1', character: '👍'}, | ||
{name: '-1', character: '👎'}, | ||
{name: 'heart', character: '❤️'}, | ||
{name: 'wave', character: '👋'}, | ||
{name: 'raised_hands', character: '🙌'}, | ||
{name: 'pray', character: '🙏'}, | ||
{name: 'clap', character: '👏'}, | ||
{name: 'ok_hand', character: '👌'}, | ||
{name: 'point_up', character: '☝️'}, | ||
{name: 'point_down', character: '👇'}, | ||
{name: 'point_left', character: '👈'}, | ||
{name: 'point_right', character: '👉'}, | ||
{name: 'raised_hand', character: '✋'}, | ||
{name: 'thumbsup', character: '👍'}, | ||
{name: 'thumbsdown', character: '👎'}, | ||
] | ||
|
||
const references = [ | ||
{id: '1', titleText: 'Add logging functionality', titleHtml: 'Add logging functionality'}, | ||
{ | ||
id: '2', | ||
titleText: 'Error: `Failed to install` when installing', | ||
titleHtml: 'Error: <code>Failed to install</code> when installing', | ||
}, | ||
{id: '3', titleText: 'Add error-handling functionality', titleHtml: 'Add error-handling functionality'}, | ||
] | ||
|
||
const mentionables = [ | ||
{identifier: 'monalisa', description: 'Monalisa Octocat'}, | ||
{identifier: 'github', description: 'GitHub'}, | ||
{identifier: 'primer', description: 'Primer'}, | ||
] | ||
|
||
const savedReplies = [ | ||
{name: 'Duplicate', content: 'Duplicate of #'}, | ||
{name: 'Welcome', content: 'Welcome to the project!\n\nPlease be sure to read the contributor guidelines.'}, | ||
{name: 'Thanks', content: 'Thanks for your contribution!'}, | ||
] | ||
|
||
const MinimalExample = () => { | ||
const [value, setValue] = React.useState('') | ||
|
||
return ( | ||
<MarkdownEditor | ||
value={value} | ||
onChange={setValue} | ||
onRenderPreview={renderMarkdown} | ||
onUploadFile={uploadFile} | ||
emojiSuggestions={emojis} | ||
referenceSuggestions={references} | ||
mentionSuggestions={mentionables} | ||
savedReplies={savedReplies} | ||
> | ||
<MarkdownEditor.Label>Suggestions, File Uploads, and Saved Replies Example</MarkdownEditor.Label> | ||
</MarkdownEditor> | ||
) | ||
} | ||
|
||
render(MinimalExample) | ||
``` | ||
|
||
### Custom Buttons | ||
|
||
```javascript live noinline drafts | ||
const renderMarkdown = async markdown => 'Rendered Markdown.' | ||
|
||
const MinimalExample = () => { | ||
const [value, setValue] = React.useState('') | ||
|
||
return ( | ||
<MarkdownEditor value={value} onChange={setValue} onRenderPreview={renderMarkdown}> | ||
<MarkdownEditor.Label visuallyHidden>Custom Buttons</MarkdownEditor.Label> | ||
|
||
<MarkdownEditor.Toolbar> | ||
<MarkdownEditor.ToolbarButton icon={SquirrelIcon} aria-label="Custom button 1" /> | ||
<MarkdownEditor.DefaultToolbarButtons /> | ||
<MarkdownEditor.ToolbarButton icon={BugIcon} aria-label="Custom button 2" /> | ||
</MarkdownEditor.Toolbar> | ||
|
||
<MarkdownEditor.Footer> | ||
<MarkdownEditor.FooterButton variant="danger">Custom Button</MarkdownEditor.FooterButton> | ||
|
||
<MarkdownEditor.Action> | ||
<MarkdownEditor.ActionButton variant="danger">Cancel</MarkdownEditor.ActionButton> | ||
<MarkdownEditor.ActionButton variant="primary">Submit</MarkdownEditor.ActionButton> | ||
</MarkdownEditor.Action> | ||
</MarkdownEditor.Footer> | ||
</MarkdownEditor> | ||
) | ||
} | ||
|
||
render(MinimalExample) | ||
``` | ||
|
||
## Props | ||
|
||
<ComponentProps data={data} /> |
This file contains 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,103 @@ | ||
--- | ||
componentId: markdown_viewer | ||
title: MarkdownViewer | ||
status: Deprecated | ||
description: Displays rendered Markdown and facilitates interaction. | ||
--- | ||
|
||
import data from '../../../packages/react/src/drafts/MarkdownViewer/MarkdownViewer.docs.json' | ||
|
||
```js | ||
import {MarkdownViewer} from '@primer/react/drafts' | ||
``` | ||
|
||
The `MarkdownViewer` displays rendered Markdown and handles interaction (link clicking and checkbox checking/unchecking) with that content. | ||
|
||
## Examples | ||
|
||
### Simple Example | ||
|
||
```javascript live noinline drafts | ||
const MarkdownViewerExample = () => { | ||
return ( | ||
// eslint-disable-next-line github/unescaped-html-literal | ||
<MarkdownViewer dangerousRenderedHTML={{__html: '<strong>Lorem ipsum</strong> dolor sit amet.'}} /> | ||
) | ||
} | ||
|
||
render(MarkdownViewerExample) | ||
``` | ||
|
||
### Link-Handling Example | ||
|
||
```javascript live noinline drafts | ||
const MarkdownViewerExample = () => { | ||
return ( | ||
<MarkdownViewer | ||
// eslint-disable-next-line github/unescaped-html-literal | ||
dangerousRenderedHTML={{__html: "<a href='https://example.com'>Example link</a>"}} | ||
onLinkClick={ev => console.log(ev)} | ||
/> | ||
) | ||
} | ||
|
||
render(MarkdownViewerExample) | ||
``` | ||
|
||
### Checkbox Interaction Example | ||
|
||
```javascript live noinline drafts | ||
const markdownSource = ` | ||
text before list | ||
- [ ] item 1 | ||
- [ ] item 2 | ||
text after list` | ||
|
||
const renderedHtml = ` | ||
<p>text before list</p> | ||
<ul class='contains-task-list'> | ||
<li class='task-list-item'><input type='checkbox' class='task-list-item-checkbox' disabled/> item 1</li> | ||
<li class='task-list-item'><input type='checkbox' class='task-list-item-checkbox' disabled/> item 2</li> | ||
</ul> | ||
<p>text after list</p>` | ||
|
||
const MarkdownViewerExample = () => { | ||
return ( | ||
<MarkdownViewer | ||
dangerousRenderedHTML={{__html: renderedHtml}} | ||
markdownValue={markdownSource} | ||
onChange={value => console.log(value) /* save the value to the server */} | ||
disabled={false} | ||
/> | ||
) | ||
} | ||
|
||
render(MarkdownViewerExample) | ||
``` | ||
|
||
## Props | ||
|
||
<ComponentProps data={data} /> | ||
|
||
## Status | ||
|
||
<ComponentChecklist | ||
items={{ | ||
propsDocumented: false, | ||
noUnnecessaryDeps: true, | ||
adaptsToThemes: true, | ||
adaptsToScreenSizes: true, | ||
fullTestCoverage: true, | ||
usedInProduction: true, | ||
usageExamplesDocumented: false, | ||
hasStorybookStories: false, | ||
designReviewed: false, | ||
a11yReviewed: false, | ||
stableApi: false, | ||
addressedApiFeedback: false, | ||
hasDesignGuidelines: false, | ||
hasFigmaComponent: false, | ||
}} | ||
/> |
This file contains 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 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 |
---|---|---|
|
@@ -101,4 +101,4 @@ | |
"lint-staged": { | ||
"**/*.{js,ts,tsx,md,mdx}": "npm run lint" | ||
} | ||
} | ||
} |
Oops, something went wrong.