Skip to content

Commit c167ff0

Browse files
authored
Fix documentation
1 parent 033ada5 commit c167ff0

File tree

5 files changed

+33
-21
lines changed

5 files changed

+33
-21
lines changed

docs/content/drafts/MarkdownEditor.mdx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ componentId: markdown_editor
33
title: MarkdownEditor
44
status: Draft
55
description: Full-featured Markdown input.
6-
source: https://github.com/primer/react/tree/main/src/MarkdownEditor
76
storybook: '/react/storybook?path=/story/forms-markdowneditor--default'
87
---
98

9+
```js
10+
import {MarkdownEditor} from '@primer/react/drafts'
11+
```
12+
1013
`MarkdownEditor` is a full-featured editor for GitHub Flavored Markdown, with support for:
1114

1215
- Formatting (keyboard shortcuts & toolbar buttons)
@@ -23,8 +26,8 @@ storybook: '/react/storybook?path=/story/forms-markdowneditor--default'
2326

2427
A `Label` is always required for accessibility:
2528

26-
```javascript live noinline
27-
const renderMarkdown = async (markdown: string) => {
29+
```javascript live noinline drafts
30+
const renderMarkdown = async (markdown) => {
2831
// In production code, this would make a query to some external API endpoint to render
2932
return "Rendered Markdown."
3033
}
@@ -48,15 +51,15 @@ render(MinimalExample)
4851

4952
### Suggestions, File Uploads, and Saved Replies
5053

51-
```javascript live noinline
52-
const renderMarkdown = async (markdown: string) => "Rendered Markdown."
54+
```javascript live noinline drafts
55+
const renderMarkdown = async (markdown) => "Rendered Markdown."
5356

54-
const uploadFile = async (file: File): FileUploadResult => ({
57+
const uploadFile = async (file) => ({
5558
url: `https://example.com/${encodeURIComponent(file.name)}`,
5659
file
5760
})
5861

59-
const emojis: Emoji[] = [
62+
const emojis = [
6063
{name: '+1', character: '👍'},
6164
{name: '-1', character: '👎'},
6265
{name: 'heart', character: '❤️'},
@@ -74,7 +77,7 @@ const emojis: Emoji[] = [
7477
{name: 'thumbsdown', character: '👎'}
7578
]
7679

77-
const references: Reference[] = [
80+
const references = [
7881
{id: '1', titleText: 'Add logging functionality', titleHtml: 'Add logging functionality'},
7982
{
8083
id: '2',
@@ -84,13 +87,13 @@ const references: Reference[] = [
8487
{id: '3', titleText: 'Add error-handling functionality', titleHtml: 'Add error-handling functionality'}
8588
]
8689

87-
const mentionables: Mentionable[] = [
90+
const mentionables = [
8891
{identifier: 'monalisa', description: 'Monalisa Octocat'},
8992
{identifier: 'github', description: 'GitHub'},
9093
{identifier: 'primer', description: 'Primer'}
9194
]
9295

93-
const savedReplies: SavedReply[] = [
96+
const savedReplies = [
9497
{name: 'Duplicate', content: 'Duplicate of #'},
9598
{name: 'Welcome', content: 'Welcome to the project!\n\nPlease be sure to read the contributor guidelines.'},
9699
{name: 'Thanks', content: 'Thanks for your contribution!'}
@@ -123,8 +126,8 @@ render(MinimalExample)
123126

124127
### Custom Buttons
125128

126-
```javascript live noinline
127-
const renderMarkdown = async (markdown: string) => "Rendered Markdown."
129+
```javascript live noinline drafts
130+
const renderMarkdown = async (markdown) => "Rendered Markdown."
128131

129132
const MinimalExample = () => {
130133
const [value, setValue] = React.useState('')

docs/content/drafts/MarkdownViewer.mdx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,23 @@ componentId: markdown_viewer
33
title: MarkdownViewer
44
status: Draft
55
description: Displays rendered Markdown and facilitates interaction.
6-
source: https://github.com/primer/react/tree/main/src/MarkdownViewer
76
---
87

8+
```js
9+
import {MarkdownViewer} from '@primer/react/drafts'
10+
```
11+
912
The `MarkdownViewer` displays rendered Markdown with appropriate styling and handles interaction (link clicking and checkbox checking/unchecking) with that content.
1013

1114
## Examples
1215

1316
### Simple Example
1417

15-
```javascript live noinline
18+
```javascript live noinline drafts
1619
const MarkdownViewerExample = () => {
1720
return (
1821
// eslint-disable-next-line github/unescaped-html-literal
19-
<MarkdownViewer dangerousRenderedHtml={{__html: "<strong>Lorem ipsum</strong> dolor sit amet."}} />
22+
<MarkdownViewer dangerousRenderedHtml={{__html: '<strong>Lorem ipsum</strong> dolor sit amet.'}} />
2023
)
2124
}
2225

@@ -25,13 +28,13 @@ render(MarkdownViewerExample)
2528

2629
### Link-Handling Example
2730

28-
```javascript live noinline
31+
```javascript live noinline drafts
2932
const MarkdownViewerExample = () => {
3033
return (
3134
<MarkdownViewer
3235
// eslint-disable-next-line github/unescaped-html-literal
3336
dangerousRenderedHtml={{__html: "<a href='https://example.com'>Example link</a>"}}
34-
onLinkClick={(ev) => console.log(ev)}
37+
onLinkClick={ev => console.log(ev)}
3538
/>
3639
)
3740
}
@@ -41,8 +44,7 @@ render(MarkdownViewerExample)
4144

4245
### Checkbox Interaction Example
4346

44-
```javascript live noinline
45-
47+
```javascript live noinline drafts
4648
const markdownSource = `
4749
text before list
4850
@@ -64,7 +66,7 @@ const MarkdownViewerExample = () => {
6466
<MarkdownViewer
6567
dangerousRenderedHtml={{__html: renderedHtml}}
6668
markdownValue={markdownSource}
67-
onChange={(value) => console.log(value) /* save the value to the server */}
69+
onChange={value => console.log(value) /* save the value to the server */}
6870
disabled={false}
6971
/>
7072
)

docs/src/@primer/gatsby-theme-doctocat/nav.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@
153153
url: /drafts/Dialog
154154
- title: InlineAutocomplete
155155
url: /drafts/InlineAutocomplete
156+
- title: MarkdownEditor
157+
url: /drafts/MarkdownEditor
158+
- title: MarkdownViewer
159+
url: /drafts/MarkdownViewer
156160
- title: Deprecated
157161
children:
158162
- title: ActionList (legacy)

src/drafts/MarkdownEditor/Toolbar.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
} from '@primer/octicons-react'
1515
import React, {forwardRef, memo, useContext, useRef} from 'react'
1616

17-
import '@github/markdown-toolbar-element'
1817
import {isMacOS} from '@primer/behaviors/utils'
1918
import Box from '../../Box'
2019
import {IconButton, IconButtonProps} from '../../Button'

src/drafts/MarkdownEditor/_FormattingTools.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import React, {forwardRef, useImperativeHandle, useRef} from 'react'
22

3+
const isBrowser = typeof window !== 'undefined'
4+
5+
if (isBrowser) import('@github/markdown-toolbar-element')
6+
37
export interface FormattingTools {
48
header: () => void
59
bold: () => void

0 commit comments

Comments
 (0)