@readme/markdown 8.1.0 → 8.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -22
- package/components/Accordion/index.tsx +5 -2
- package/components/Anchor.jsx +1 -1
- package/components/Callout/index.tsx +5 -4
- package/components/Cards/index.tsx +17 -5
- package/components/Code/index.tsx +11 -2
- package/components/CodeTabs/index.tsx +5 -1
- package/components/Columns/index.tsx +7 -6
- package/components/Embed/index.tsx +10 -7
- package/components/Glossary/index.tsx +8 -4
- package/components/HTMLBlock/index.tsx +10 -2
- package/components/Heading/index.tsx +6 -2
- package/components/Image/index.tsx +15 -13
- package/components/Table/index.tsx +2 -2
- package/components/Tabs/index.tsx +21 -14
- package/components/TailwindRoot/index.tsx +3 -1
- package/dist/components/Accordion/index.d.ts +7 -6
- package/dist/components/Callout/index.d.ts +2 -2
- package/dist/components/Cards/index.d.ts +13 -11
- package/dist/components/CodeTabs/index.d.ts +5 -1
- package/dist/components/Columns/index.d.ts +6 -7
- package/dist/components/Embed/index.d.ts +6 -6
- package/dist/components/Glossary/index.d.ts +4 -3
- package/dist/components/HTMLBlock/index.d.ts +5 -4
- package/dist/components/Heading/index.d.ts +1 -1
- package/dist/components/Image/index.d.ts +2 -2
- package/dist/components/Table/index.d.ts +2 -2
- package/dist/components/Tabs/index.d.ts +5 -6
- package/dist/components/TailwindRoot/index.d.ts +5 -4
- package/dist/contexts/GlossaryTerms.d.ts +4 -4
- package/dist/contexts/index.d.ts +2 -2
- package/dist/errors/mdx-syntax-error.d.ts +1 -1
- package/dist/example/RenderError.d.ts +5 -4
- package/dist/lib/ast-processor.d.ts +5 -5
- package/dist/lib/compile.d.ts +1 -3
- package/dist/lib/hast.d.ts +1 -1
- package/dist/lib/mdast.d.ts +3 -1
- package/dist/lib/mdastV6.d.ts +4 -1
- package/dist/lib/mdx.d.ts +3 -1
- package/dist/lib/plain.d.ts +1 -1
- package/dist/lib/run.d.ts +6 -12
- package/dist/main.js +28652 -28499
- package/dist/main.node.js +29301 -29148
- package/dist/main.node.js.map +1 -1
- package/dist/processor/compile/callout.d.ts +1 -1
- package/dist/processor/compile/code-tabs.d.ts +1 -1
- package/dist/processor/compile/compatibility.d.ts +20 -31
- package/dist/processor/compile/embed.d.ts +1 -1
- package/dist/processor/compile/gemoji.d.ts +1 -1
- package/dist/processor/compile/html-block.d.ts +1 -1
- package/dist/processor/compile/variable.d.ts +1 -1
- package/dist/processor/plugin/toc.d.ts +4 -4
- package/dist/processor/transform/callouts.d.ts +2 -1
- package/dist/processor/transform/code-tabs.d.ts +1 -1
- package/dist/processor/transform/compatability.d.ts +1 -1
- package/dist/processor/transform/div.d.ts +1 -1
- package/dist/processor/transform/embeds.d.ts +1 -1
- package/dist/processor/transform/gemoji+.d.ts +1 -1
- package/dist/processor/transform/images.d.ts +1 -1
- package/dist/processor/transform/index.d.ts +4 -4
- package/dist/processor/transform/inject-components.d.ts +2 -2
- package/dist/processor/transform/mdx-to-hast.d.ts +1 -1
- package/dist/processor/transform/mermaid.d.ts +1 -1
- package/dist/processor/transform/readme-components.d.ts +1 -1
- package/dist/processor/transform/readme-to-mdx.d.ts +1 -1
- package/dist/processor/transform/tables-to-jsx.d.ts +1 -1
- package/dist/processor/transform/tailwind.d.ts +1 -1
- package/dist/processor/transform/variables.d.ts +1 -1
- package/dist/processor/utils.d.ts +9 -8
- package/dist/utils/user.d.ts +2 -2
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
<img
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://npm.im/@readme/markdown">
|
|
3
|
+
<img src="https://owlbertsio-resized.s3.amazonaws.com/Reading.psd.full.png" width="150" alt="rmdx" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
ReadMe's MDX rendering engine and custom component collection.<br />
|
|
9
|
+
<sub>
|
|
10
|
+
Use ReadMe? <a href="https://docs.readme.com/rdmd/page/mdx-engine">Learn more about our upcoming move to MDX!</a>
|
|
11
|
+
</sub>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<a href="https://npm.im/@readme/markdown"><img src="https://img.shields.io/npm/v/@readme/markdown?style=for-the-badge" alt="NPM Version" /></a>
|
|
16
|
+
<a href="https://npm.im/@readme/markdown"><img src="https://img.shields.io/npm/l/@readme/markdown?style=for-the-badge" alt="MIT License" /></a>
|
|
17
|
+
<a href="https://github.com/readmeio/markdown"><img src="https://img.shields.io/github/actions/workflow/status/readmeio/markdown/ci.yml?branch=main&style=for-the-badge" alt="Build status" /></a>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
<p align="center">
|
|
21
|
+
<a href="https://readme.com"><img src="https://raw.githubusercontent.com/readmeio/.github/main/oss-badge.svg" /></a>
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
7
25
|
|
|
8
26
|
To use the engine, install it from NPM:
|
|
9
27
|
|
|
@@ -16,11 +34,7 @@ Then [`compile`](#compile) and [`run`](#run) your MDX:
|
|
|
16
34
|
```jsx
|
|
17
35
|
import RMDX from '@readme/markdown';
|
|
18
36
|
|
|
19
|
-
export default ({ body }) => (
|
|
20
|
-
<div className="markdown-body">
|
|
21
|
-
{RMDX.run(RMDX.compile(body))}
|
|
22
|
-
</div>
|
|
23
|
-
);
|
|
37
|
+
export default ({ body }) => <div className="markdown-body">{RMDX.run(RMDX.compile(body))}</div>;
|
|
24
38
|
```
|
|
25
39
|
|
|
26
40
|
## API
|
|
@@ -42,13 +56,15 @@ A string of compiled Javascript module code.
|
|
|
42
56
|
|
|
43
57
|
> [!CAUTION]
|
|
44
58
|
> This is essentially a wrapper around [`mdx.run`](https://mdxjs.com/packages/mdx/#runcode-options) and **it will `eval` the compiled MDX**. Make sure you only call `run` on safe syntax from a trusted author!
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
|
|
60
|
+
#### Parameters
|
|
61
|
+
|
|
62
|
+
- **`string`** (`string`)—a compiled mdx document
|
|
63
|
+
- **`opts`** (`RunOpts`, optional)—configuration
|
|
64
|
+
|
|
65
|
+
#### Returns
|
|
66
|
+
|
|
67
|
+
An [`RMDXModule`](#rmdxmodule) of renderable components.
|
|
52
68
|
|
|
53
69
|
### `mdx`
|
|
54
70
|
|
|
@@ -57,7 +73,7 @@ Compiles an AST to a string of MDX syntax.
|
|
|
57
73
|
#### Parameters
|
|
58
74
|
|
|
59
75
|
- **`tree`** (`object`)—an abstract syntax tree
|
|
60
|
-
- **`opts`** ([`Options`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#options
|
|
76
|
+
- **`opts`** ([`Options`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#options '`remark-stringify` Options type'))—`remark-stringify` configuration.
|
|
61
77
|
|
|
62
78
|
#### Returns
|
|
63
79
|
|
|
@@ -67,8 +83,8 @@ An MDX string.
|
|
|
67
83
|
|
|
68
84
|
- **`mdast`**: parse MDX syntax to MDAST.
|
|
69
85
|
- **`hast`**: parse MDX syntax to HAST.
|
|
70
|
-
- **`plain`**: parse MDX to a plaintext string with all Markdown syntax removed. (This
|
|
71
|
-
- **`tags`**: get a list of tag names from the doc. (This
|
|
86
|
+
- **`plain`**: parse MDX to a plaintext string with all Markdown syntax removed. (This _does not_ `eval` the doc.)
|
|
87
|
+
- **`tags`**: get a list of tag names from the doc. (This _does not_ `eval` the doc.)
|
|
72
88
|
- **`utils`**: additional defaults, helper methods, components, and so on.
|
|
73
89
|
|
|
74
90
|
## Types
|
|
@@ -103,7 +119,7 @@ Extends [`RunOptions`](https://mdxjs.com/packages/mdx/#runoptions)
|
|
|
103
119
|
- **`toc`** (`HastHeading[]`)—a list of headings in the document
|
|
104
120
|
- **`Toc`** (`() => MDCContent`)—a table of contents component
|
|
105
121
|
|
|
106
|
-
## Local
|
|
122
|
+
## Local development and testing
|
|
107
123
|
|
|
108
124
|
To make changes to the RDMD engine locally, run the local development server. Clone the repo, `cd` in to it, `npm install`, and `npm run start`!
|
|
109
125
|
|
|
@@ -2,7 +2,9 @@ import React, { useState } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import './style.scss';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
interface Props extends React.PropsWithChildren<{ icon?: string; iconColor?: string; title: string }> {}
|
|
6
|
+
|
|
7
|
+
const Accordion = ({ children, icon, iconColor, title }: Props) => {
|
|
6
8
|
const [isOpen, setIsOpen] = useState(false);
|
|
7
9
|
|
|
8
10
|
return (
|
|
@@ -17,4 +19,5 @@ const Accordion = ({ children, icon, iconColor, title }) => {
|
|
|
17
19
|
);
|
|
18
20
|
};
|
|
19
21
|
|
|
20
|
-
export default Accordion;
|
|
22
|
+
export default Accordion;
|
|
23
|
+
|
package/components/Anchor.jsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
3
|
interface Props extends React.PropsWithChildren<React.HTMLAttributes<HTMLQuoteElement>> {
|
|
4
|
-
attributes?:
|
|
4
|
+
attributes?: Record<string, unknown>;
|
|
5
|
+
empty?: boolean;
|
|
5
6
|
icon: string;
|
|
6
7
|
theme?: string;
|
|
7
|
-
empty?: boolean;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
const themes: Record<string, string> = {
|
|
@@ -24,10 +24,11 @@ const themes: Record<string, string> = {
|
|
|
24
24
|
|
|
25
25
|
const Callout = (props: Props) => {
|
|
26
26
|
const { attributes, children, icon, empty } = props;
|
|
27
|
-
|
|
27
|
+
const theme = props.theme || themes[icon] || 'default';
|
|
28
28
|
|
|
29
29
|
return (
|
|
30
|
-
// @ts-
|
|
30
|
+
// @ts-expect-error -- theme is not a valid attribute
|
|
31
|
+
// eslint-disable-next-line react/jsx-props-no-spreading, react/no-unknown-property
|
|
31
32
|
<blockquote {...attributes} className={`callout callout_${theme}`} theme={icon}>
|
|
32
33
|
<h3 className={`callout-heading${empty ? ' empty' : ''}`}>
|
|
33
34
|
<span className="callout-icon">{icon}</span>
|
|
@@ -2,18 +2,30 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import './style.scss';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
interface CardProps
|
|
6
|
+
extends React.PropsWithChildren<{
|
|
7
|
+
href?: string;
|
|
8
|
+
icon?: string;
|
|
9
|
+
iconColor?: string;
|
|
10
|
+
target?: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
}> {}
|
|
13
|
+
|
|
14
|
+
export const Card = ({ children, href, icon, iconColor, target, title }: CardProps) => {
|
|
6
15
|
const Tag = href ? 'a' : 'div';
|
|
7
16
|
return (
|
|
8
17
|
<Tag className="Card" href={href} target={target}>
|
|
9
18
|
{icon && <i className={`Card-icon fa-duotone fa-solid ${icon}`} style={{ color: `${iconColor}` }}></i>}
|
|
10
|
-
{title && <p className=
|
|
19
|
+
{title && <p className="Card-title">{title}</p>}
|
|
11
20
|
<div className="Card-content">{children}</div>
|
|
12
21
|
</Tag>
|
|
13
|
-
)
|
|
14
|
-
}
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
interface CardsGripProps extends React.PropsWithChildren<{ columns?: number }> {}
|
|
15
26
|
|
|
16
|
-
const CardsGrid = ({ columns = 2, children }) => {
|
|
27
|
+
const CardsGrid = ({ columns = 2, children }: CardsGripProps) => {
|
|
28
|
+
// eslint-disable-next-line no-param-reassign
|
|
17
29
|
columns = columns >= 2 ? columns : 2;
|
|
18
30
|
return (
|
|
19
31
|
<div className="CardsGrid" style={{ gridTemplateColumns: `repeat(${columns}, 1fr)` }}>
|
|
@@ -5,7 +5,8 @@ import React, { createRef } from 'react';
|
|
|
5
5
|
// apps. Necessary because of people like this:
|
|
6
6
|
// https://github.com/codemirror/CodeMirror/issues/3701#issuecomment-164904534
|
|
7
7
|
let syntaxHighlighter;
|
|
8
|
-
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9
|
+
let canonicalLanguage = lang => '';
|
|
9
10
|
|
|
10
11
|
if (typeof window !== 'undefined') {
|
|
11
12
|
import('@readme/syntax-highlighter').then(module => {
|
|
@@ -14,7 +15,15 @@ if (typeof window !== 'undefined') {
|
|
|
14
15
|
});
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
function CopyCode({
|
|
18
|
+
function CopyCode({
|
|
19
|
+
codeRef,
|
|
20
|
+
rootClass = 'rdmd-code-copy',
|
|
21
|
+
className = '',
|
|
22
|
+
}: {
|
|
23
|
+
className?: string;
|
|
24
|
+
codeRef: React.RefObject<HTMLElement>;
|
|
25
|
+
rootClass?: string;
|
|
26
|
+
}) {
|
|
18
27
|
const copyClass = `${rootClass}_copied`;
|
|
19
28
|
const buttonRef = createRef<HTMLButtonElement>();
|
|
20
29
|
|
|
@@ -5,8 +5,12 @@ import React, { useEffect } from 'react';
|
|
|
5
5
|
|
|
6
6
|
let mermaid: Mermaid;
|
|
7
7
|
|
|
8
|
+
interface Props {
|
|
9
|
+
children: JSX.Element | JSX.Element[];
|
|
10
|
+
theme: 'dark' | 'default' | 'light';
|
|
11
|
+
}
|
|
8
12
|
|
|
9
|
-
const CodeTabs = props => {
|
|
13
|
+
const CodeTabs = (props: Props) => {
|
|
10
14
|
const { children, theme } = props;
|
|
11
15
|
|
|
12
16
|
// render Mermaid diagram
|
|
@@ -2,13 +2,14 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import './style.scss';
|
|
4
4
|
|
|
5
|
-
export const Column = ({ children }) => {
|
|
6
|
-
return
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
5
|
+
export const Column = ({ children }: React.PropsWithChildren) => {
|
|
6
|
+
return <div className="Column">{children}</div>;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
interface Props extends React.PropsWithChildren<{ layout?: '1fr' | 'auto' | 'fixed' }> {}
|
|
10
10
|
|
|
11
|
-
const Columns = ({ children, layout = 'auto'}) => {
|
|
11
|
+
const Columns = ({ children, layout = 'auto' }: Props) => {
|
|
12
|
+
// eslint-disable-next-line no-param-reassign
|
|
12
13
|
layout = layout === 'fixed' ? '1fr' : 'auto';
|
|
13
14
|
const columnsCount = React.Children.count(children);
|
|
14
15
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
/* eslint-disable no-param-reassign */
|
|
2
|
+
/* eslint-disable react/jsx-props-no-spreading */
|
|
1
3
|
import React from 'react';
|
|
2
4
|
|
|
3
5
|
interface FaviconProps {
|
|
4
|
-
src: string;
|
|
5
6
|
alt?: string;
|
|
7
|
+
src: string;
|
|
6
8
|
}
|
|
7
9
|
|
|
8
10
|
const Favicon = ({ src, alt = 'favicon', ...attr }: FaviconProps) => (
|
|
@@ -10,16 +12,16 @@ const Favicon = ({ src, alt = 'favicon', ...attr }: FaviconProps) => (
|
|
|
10
12
|
);
|
|
11
13
|
|
|
12
14
|
interface EmbedProps {
|
|
13
|
-
|
|
14
|
-
url: string;
|
|
15
|
-
title: string;
|
|
16
|
-
providerName?: string;
|
|
17
|
-
providerUrl?: string;
|
|
15
|
+
favicon?: string;
|
|
18
16
|
html?: string;
|
|
19
17
|
iframe?: boolean;
|
|
20
18
|
image?: string;
|
|
21
|
-
|
|
19
|
+
lazy?: boolean;
|
|
20
|
+
providerName?: string;
|
|
21
|
+
providerUrl?: string;
|
|
22
|
+
title: string;
|
|
22
23
|
typeOfEmbed?: string;
|
|
24
|
+
url: string;
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
const Embed = ({
|
|
@@ -50,6 +52,7 @@ const Embed = ({
|
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
if (iframe) {
|
|
55
|
+
// eslint-disable-next-line jsx-a11y/iframe-has-title
|
|
53
56
|
return <iframe {...attrs} src={url} style={{ border: 'none', display: 'flex', margin: 'auto' }} />;
|
|
54
57
|
}
|
|
55
58
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { GlossaryTerm } from '../../contexts/GlossaryTerms';
|
|
2
|
+
|
|
2
3
|
import Tooltip from '@tippyjs/react';
|
|
4
|
+
import React, { useContext } from 'react';
|
|
5
|
+
|
|
3
6
|
import GlossaryContext from '../../contexts/GlossaryTerms';
|
|
4
|
-
import type { GlossaryTerm } from '../../contexts/GlossaryTerms';
|
|
5
7
|
|
|
6
8
|
interface Props extends React.PropsWithChildren {
|
|
7
9
|
term?: string;
|
|
@@ -29,9 +31,11 @@ const Glossary = ({ children, term: termProp, terms }: Props) => {
|
|
|
29
31
|
);
|
|
30
32
|
};
|
|
31
33
|
|
|
32
|
-
const GlossaryWithContext = props => {
|
|
34
|
+
const GlossaryWithContext = (props: Omit<Props, 'terms'>) => {
|
|
33
35
|
const terms = useContext(GlossaryContext);
|
|
34
36
|
return terms ? <Glossary {...props} terms={terms} /> : <span>{props.term}</span>;
|
|
35
37
|
};
|
|
36
38
|
|
|
37
|
-
export { Glossary,
|
|
39
|
+
export { Glossary, GlossaryContext };
|
|
40
|
+
|
|
41
|
+
export default GlossaryWithContext;
|
|
@@ -10,12 +10,20 @@ const extractScripts = (html: string = ''): [string, () => void] => {
|
|
|
10
10
|
scripts.push(match[1]);
|
|
11
11
|
}
|
|
12
12
|
const cleaned = html.replace(MATCH_SCRIPT_TAGS, '');
|
|
13
|
+
// eslint-disable-next-line no-eval
|
|
13
14
|
return [cleaned, () => scripts.map(js => window.eval(js))];
|
|
14
15
|
};
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
interface Props {
|
|
18
|
+
children: React.ReactElement | string;
|
|
19
|
+
runScripts?: boolean | string;
|
|
20
|
+
safeMode?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const HTMLBlock = ({ children = '', runScripts, safeMode = false }: Props) => {
|
|
17
24
|
let html = children;
|
|
18
|
-
|
|
25
|
+
// eslint-disable-next-line no-param-reassign
|
|
26
|
+
runScripts = typeof runScripts !== 'boolean' ? runScripts === 'true' : runScripts;
|
|
19
27
|
|
|
20
28
|
if (typeof html !== 'string') html = renderToStaticMarkup(html);
|
|
21
29
|
const [cleanedHtml, exec] = extractScripts(html);
|
|
@@ -3,8 +3,8 @@ import React from 'react';
|
|
|
3
3
|
export type Depth = 1 | 2 | 3 | 4 | 5 | 6;
|
|
4
4
|
|
|
5
5
|
interface Props extends React.PropsWithChildren<React.HTMLAttributes<HTMLHeadingElement>> {
|
|
6
|
-
tag: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
7
6
|
depth: Depth;
|
|
7
|
+
tag: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
const Heading = ({ tag: Tag = 'h3', depth = 3, id, children, ...attrs }: Props) => {
|
|
@@ -26,6 +26,10 @@ const Heading = ({ tag: Tag = 'h3', depth = 3, id, children, ...attrs }: Props)
|
|
|
26
26
|
);
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
const CreateHeading = (depth: Depth) =>
|
|
29
|
+
const CreateHeading = (depth: Depth) => {
|
|
30
|
+
const HeadingWithDepth = (props: Props) => <Heading {...props} depth={depth} tag={`h${depth}`} />;
|
|
31
|
+
|
|
32
|
+
return HeadingWithDepth;
|
|
33
|
+
};
|
|
30
34
|
|
|
31
35
|
export default CreateHeading;
|
|
@@ -5,13 +5,13 @@ interface ImageProps {
|
|
|
5
5
|
alt?: string;
|
|
6
6
|
border?: boolean;
|
|
7
7
|
caption?: string;
|
|
8
|
+
children?: [React.ReactElement];
|
|
8
9
|
className?: string;
|
|
9
10
|
height?: string;
|
|
11
|
+
lazy?: boolean;
|
|
10
12
|
src: string;
|
|
11
13
|
title?: string;
|
|
12
14
|
width?: string;
|
|
13
|
-
lazy?: boolean;
|
|
14
|
-
children?: [React.ReactElement];
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const Image = (Props: ImageProps) => {
|
|
@@ -32,11 +32,12 @@ const Image = (Props: ImageProps) => {
|
|
|
32
32
|
const [lightbox, setLightbox] = React.useState(false);
|
|
33
33
|
|
|
34
34
|
if (className === 'emoji') {
|
|
35
|
-
return <img
|
|
35
|
+
return <img alt={alt} height={height} loading={lazy ? 'lazy' : 'eager'} src={src} title={title} width={width} />;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
const handleKeyDown = ({ key, metaKey: cmd }: React.KeyboardEvent<HTMLImageElement>) => {
|
|
39
39
|
const cmdKey = cmd ? 'cmd+' : '';
|
|
40
|
+
// eslint-disable-next-line no-param-reassign
|
|
40
41
|
key = `${cmdKey}${key.toLowerCase()}`;
|
|
41
42
|
|
|
42
43
|
switch (key) {
|
|
@@ -49,6 +50,7 @@ const Image = (Props: ImageProps) => {
|
|
|
49
50
|
case 'enter':
|
|
50
51
|
// OPEN
|
|
51
52
|
if (!lightbox) setLightbox(true);
|
|
53
|
+
break;
|
|
52
54
|
default:
|
|
53
55
|
}
|
|
54
56
|
};
|
|
@@ -71,13 +73,13 @@ const Image = (Props: ImageProps) => {
|
|
|
71
73
|
>
|
|
72
74
|
<span className="lightbox-inner">
|
|
73
75
|
<img
|
|
74
|
-
src={src}
|
|
75
|
-
width={width}
|
|
76
|
-
height={height}
|
|
77
|
-
title={title}
|
|
78
|
-
className={`img img-align-center ${border ? 'border' : ''}`}
|
|
79
76
|
alt={alt}
|
|
77
|
+
className={`img img-align-center ${border ? 'border' : ''}`}
|
|
78
|
+
height={height}
|
|
80
79
|
loading={lazy ? 'lazy' : 'eager'}
|
|
80
|
+
src={src}
|
|
81
|
+
title={title}
|
|
82
|
+
width={width}
|
|
81
83
|
/>
|
|
82
84
|
<figcaption>{children || caption}</figcaption>
|
|
83
85
|
</span>
|
|
@@ -97,13 +99,13 @@ const Image = (Props: ImageProps) => {
|
|
|
97
99
|
>
|
|
98
100
|
<span className="lightbox-inner">
|
|
99
101
|
<img
|
|
100
|
-
src={src}
|
|
101
|
-
width={width}
|
|
102
|
-
height={height}
|
|
103
|
-
title={title}
|
|
104
|
-
className={`img ${align ? `img-align-${align}` : ''} ${border ? 'border' : ''}`}
|
|
105
102
|
alt={alt}
|
|
103
|
+
className={`img ${align ? `img-align-${align}` : ''} ${border ? 'border' : ''}`}
|
|
104
|
+
height={height}
|
|
106
105
|
loading={lazy ? 'lazy' : 'eager'}
|
|
106
|
+
src={src}
|
|
107
|
+
title={title}
|
|
108
|
+
width={width}
|
|
107
109
|
/>
|
|
108
110
|
</span>
|
|
109
111
|
</span>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
interface Props extends JSX.IntrinsicAttributes {
|
|
4
|
-
align: ('
|
|
5
|
-
children: [React.ReactElement<HTMLTableCaptionElement |
|
|
4
|
+
align: ('center' | 'left' | 'right')[];
|
|
5
|
+
children: [React.ReactElement<HTMLTableCaptionElement | HTMLTableRowElement | HTMLTableSectionElement>];
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
const Table = (props: Props) => {
|
|
@@ -2,32 +2,39 @@ import React, { useState } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import './style.scss';
|
|
4
4
|
|
|
5
|
-
export const Tab = ({ children }) => {
|
|
6
|
-
return
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
export const Tab = ({ children }: React.PropsWithChildren) => {
|
|
6
|
+
return <div className="TabContent">{children}</div>;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
interface TabsProps {
|
|
10
|
+
children?: React.ReactElement[];
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
const Tabs = ({ children }) => {
|
|
13
|
+
const Tabs = ({ children }: TabsProps) => {
|
|
14
14
|
const [activeTab, setActiveTab] = useState(0);
|
|
15
15
|
|
|
16
16
|
return (
|
|
17
17
|
<div className="TabGroup">
|
|
18
18
|
<header>
|
|
19
19
|
<nav className="TabGroup-nav">
|
|
20
|
-
{children?.map((tab, index: number) =>
|
|
21
|
-
<button
|
|
22
|
-
|
|
20
|
+
{children?.map((tab, index: number) => (
|
|
21
|
+
<button
|
|
22
|
+
key={tab.props.title}
|
|
23
|
+
className={`TabGroup-tab${activeTab === index ? '_active' : ''}`}
|
|
24
|
+
onClick={() => setActiveTab(index)}
|
|
25
|
+
>
|
|
26
|
+
{tab.props.icon && (
|
|
27
|
+
<i
|
|
28
|
+
className={`TabGroup-icon fa-duotone fa-solid ${tab.props.icon}`}
|
|
29
|
+
style={{ color: `${tab.props.iconColor}` }}
|
|
30
|
+
></i>
|
|
31
|
+
)}
|
|
23
32
|
{tab.props.title}
|
|
24
33
|
</button>
|
|
25
|
-
)}
|
|
34
|
+
))}
|
|
26
35
|
</nav>
|
|
27
36
|
</header>
|
|
28
|
-
<section>
|
|
29
|
-
{children && children[activeTab]}
|
|
30
|
-
</section>
|
|
37
|
+
<section>{children && children[activeTab]}</section>
|
|
31
38
|
</div>
|
|
32
39
|
);
|
|
33
40
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
interface Props extends React.PropsWithChildren<{ flow: boolean }> {}
|
|
4
|
+
|
|
5
|
+
const TailwindRoot = ({ children, flow }: Props) => {
|
|
4
6
|
const Tag = flow ? 'div' : 'span';
|
|
5
7
|
|
|
6
8
|
return <Tag className="readme-tailwind">{children}</Tag>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './style.scss';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
3
|
+
interface Props extends React.PropsWithChildren<{
|
|
4
|
+
icon?: string;
|
|
5
|
+
iconColor?: string;
|
|
6
|
+
title: string;
|
|
7
|
+
}> {
|
|
8
|
+
}
|
|
9
|
+
declare const Accordion: ({ children, icon, iconColor, title }: Props) => React.JSX.Element;
|
|
9
10
|
export default Accordion;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
interface Props extends React.PropsWithChildren<React.HTMLAttributes<HTMLQuoteElement>> {
|
|
3
|
-
attributes?:
|
|
3
|
+
attributes?: Record<string, unknown>;
|
|
4
|
+
empty?: boolean;
|
|
4
5
|
icon: string;
|
|
5
6
|
theme?: string;
|
|
6
|
-
empty?: boolean;
|
|
7
7
|
}
|
|
8
8
|
declare const Callout: (props: Props) => React.JSX.Element;
|
|
9
9
|
export default Callout;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './style.scss';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
declare const
|
|
3
|
+
interface CardProps extends React.PropsWithChildren<{
|
|
4
|
+
href?: string;
|
|
5
|
+
icon?: string;
|
|
6
|
+
iconColor?: string;
|
|
7
|
+
target?: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
}> {
|
|
10
|
+
}
|
|
11
|
+
export declare const Card: ({ children, href, icon, iconColor, target, title }: CardProps) => React.JSX.Element;
|
|
12
|
+
interface CardsGripProps extends React.PropsWithChildren<{
|
|
12
13
|
columns?: number;
|
|
13
|
-
|
|
14
|
-
}
|
|
14
|
+
}> {
|
|
15
|
+
}
|
|
16
|
+
declare const CardsGrid: ({ columns, children }: CardsGripProps) => React.JSX.Element;
|
|
15
17
|
export default CardsGrid;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
2
|
+
interface Props {
|
|
3
|
+
children: JSX.Element | JSX.Element[];
|
|
4
|
+
theme: 'dark' | 'default' | 'light';
|
|
5
|
+
}
|
|
6
|
+
declare const CodeTabs: (props: Props) => React.JSX.Element;
|
|
3
7
|
export default CodeTabs;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './style.scss';
|
|
3
|
-
export declare const Column: ({ children }:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}) => React.JSX.Element;
|
|
3
|
+
export declare const Column: ({ children }: React.PropsWithChildren) => React.JSX.Element;
|
|
4
|
+
interface Props extends React.PropsWithChildren<{
|
|
5
|
+
layout?: '1fr' | 'auto' | 'fixed';
|
|
6
|
+
}> {
|
|
7
|
+
}
|
|
8
|
+
declare const Columns: ({ children, layout }: Props) => React.JSX.Element;
|
|
10
9
|
export default Columns;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
interface EmbedProps {
|
|
3
|
-
|
|
4
|
-
url: string;
|
|
5
|
-
title: string;
|
|
6
|
-
providerName?: string;
|
|
7
|
-
providerUrl?: string;
|
|
3
|
+
favicon?: string;
|
|
8
4
|
html?: string;
|
|
9
5
|
iframe?: boolean;
|
|
10
6
|
image?: string;
|
|
11
|
-
|
|
7
|
+
lazy?: boolean;
|
|
8
|
+
providerName?: string;
|
|
9
|
+
providerUrl?: string;
|
|
10
|
+
title: string;
|
|
12
11
|
typeOfEmbed?: string;
|
|
12
|
+
url: string;
|
|
13
13
|
}
|
|
14
14
|
declare const Embed: ({ lazy, url, html, providerName, providerUrl, title, iframe, image, favicon, ...attrs }: EmbedProps) => React.JSX.Element;
|
|
15
15
|
export default Embed;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import type { GlossaryTerm } from '../../contexts/GlossaryTerms';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import GlossaryContext from '../../contexts/GlossaryTerms';
|
|
3
|
-
import type { GlossaryTerm } from '../../contexts/GlossaryTerms';
|
|
4
4
|
interface Props extends React.PropsWithChildren {
|
|
5
5
|
term?: string;
|
|
6
6
|
terms: GlossaryTerm[];
|
|
7
7
|
}
|
|
8
8
|
declare const Glossary: ({ children, term: termProp, terms }: Props) => React.JSX.Element;
|
|
9
|
-
declare const GlossaryWithContext: (props:
|
|
10
|
-
export { Glossary,
|
|
9
|
+
declare const GlossaryWithContext: (props: Omit<Props, "terms">) => React.JSX.Element;
|
|
10
|
+
export { Glossary, GlossaryContext };
|
|
11
|
+
export default GlossaryWithContext;
|