@readme/markdown 6.75.0-beta.33 → 6.75.0-beta.34
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/components/Callout/index.tsx +1 -1
- package/components/Code/index.tsx +3 -2
- package/components/Embed/index.tsx +68 -0
- package/components/Image/index.tsx +26 -12
- package/dist/components/Callout/index.d.ts +1 -1
- package/dist/components/Code/index.d.ts +3 -2
- package/dist/components/Embed/index.d.ts +13 -0
- package/dist/components/Image/index.d.ts +5 -4
- package/dist/enums.d.ts +3 -2
- package/dist/main.js +110 -440
- package/dist/main.node.js +110 -159
- package/dist/processor/compile/embed.d.ts +3 -0
- package/dist/processor/transform/code-tabs.d.ts +2 -2
- package/dist/processor/transform/embeds.d.ts +2 -0
- package/package.json +1 -1
- package/components/Embed/index.jsx +0 -89
|
@@ -32,7 +32,8 @@ function CopyCode({ codeRef, rootClass = 'rdmd-code-copy', className = '' }) {
|
|
|
32
32
|
return <button ref={button} aria-label="Copy Code" className={`${rootClass} ${className}`} onClick={copier} />;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
interface
|
|
35
|
+
interface CodeProps {
|
|
36
|
+
children?: string[] | string;
|
|
36
37
|
copyButtons?: boolean;
|
|
37
38
|
lang?: string;
|
|
38
39
|
meta?: string;
|
|
@@ -40,7 +41,7 @@ interface Props extends Omit<HTMLElement, 'lang'> {
|
|
|
40
41
|
value?: string;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
const Code = (props:
|
|
44
|
+
const Code = (props: CodeProps) => {
|
|
44
45
|
const { children, copyButtons, lang, theme, value } = props;
|
|
45
46
|
|
|
46
47
|
const language = canonicalLanguage(lang);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface FaviconProps {
|
|
4
|
+
src: string;
|
|
5
|
+
alt?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const Favicon = ({ src, alt = 'favicon', ...attr }: FaviconProps) => (
|
|
9
|
+
<img {...attr} alt={alt} height="14" src={src} width="14" />
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
interface EmbedProps {
|
|
13
|
+
lazy?: boolean;
|
|
14
|
+
url: string;
|
|
15
|
+
title: string;
|
|
16
|
+
provider?: string;
|
|
17
|
+
html?: string;
|
|
18
|
+
iframe?: boolean;
|
|
19
|
+
image?: string;
|
|
20
|
+
favicon?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const Embed = ({ lazy = true, url, provider, title, html, iframe, image, favicon, ...attrs }: EmbedProps) => {
|
|
24
|
+
if (iframe) {
|
|
25
|
+
return <iframe {...attrs} src={url} style={{ border: 'none', display: 'flex', margin: 'auto' }} />;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!provider)
|
|
29
|
+
provider = new URL(url).hostname
|
|
30
|
+
.split(/(?:www)?\./)
|
|
31
|
+
.filter(i => i)
|
|
32
|
+
.join('.');
|
|
33
|
+
|
|
34
|
+
const classes = ['embed', image ? 'embed_hasImg' : ''];
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div className={classes.join(' ')}>
|
|
38
|
+
{html ? (
|
|
39
|
+
<div className="embed-media" dangerouslySetInnerHTML={{ __html: html }} />
|
|
40
|
+
) : (
|
|
41
|
+
<a className="embed-link" href={url} rel="noopener noreferrer" target="_blank">
|
|
42
|
+
{!image || <img alt={title} className="embed-img" loading={lazy ? 'lazy' : undefined} src={image} />}
|
|
43
|
+
{title ? (
|
|
44
|
+
<div className="embed-body">
|
|
45
|
+
{!favicon || <Favicon alt={provider} src={favicon} />}
|
|
46
|
+
{provider && (
|
|
47
|
+
<small className="embed-provider">
|
|
48
|
+
{provider.search(/^@{1}/) < 0 ? (
|
|
49
|
+
provider
|
|
50
|
+
) : (
|
|
51
|
+
<code style={{ fontFamily: 'var(--md-code-font, monospace)' }}>{url}</code>
|
|
52
|
+
)}
|
|
53
|
+
</small>
|
|
54
|
+
)}
|
|
55
|
+
<div className="embed-title">{title}</div>
|
|
56
|
+
</div>
|
|
57
|
+
) : (
|
|
58
|
+
<div className="embed-body">
|
|
59
|
+
<b>View</b>: <span className="embed-body-url">{url}</span>
|
|
60
|
+
</div>
|
|
61
|
+
)}
|
|
62
|
+
</a>
|
|
63
|
+
)}
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export default Embed;
|
|
@@ -1,18 +1,32 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
align
|
|
5
|
-
alt
|
|
6
|
-
border
|
|
7
|
-
caption
|
|
8
|
-
className
|
|
9
|
-
height
|
|
10
|
-
src
|
|
11
|
-
title
|
|
12
|
-
width
|
|
13
|
-
lazy
|
|
14
|
-
}
|
|
3
|
+
interface ImageProps {
|
|
4
|
+
align?: string;
|
|
5
|
+
alt?: string;
|
|
6
|
+
border?: boolean;
|
|
7
|
+
caption?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
height?: string;
|
|
10
|
+
src: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
width?: string;
|
|
13
|
+
lazy?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const Image = (Props: ImageProps) => {
|
|
15
17
|
const [lightbox, setLightbox] = React.useState(false);
|
|
18
|
+
const {
|
|
19
|
+
align = '',
|
|
20
|
+
alt = '',
|
|
21
|
+
border = false,
|
|
22
|
+
caption,
|
|
23
|
+
className = '',
|
|
24
|
+
height = 'auto',
|
|
25
|
+
src,
|
|
26
|
+
title = '',
|
|
27
|
+
width = 'auto',
|
|
28
|
+
lazy = false,
|
|
29
|
+
} = Props;
|
|
16
30
|
|
|
17
31
|
if (className === 'emoji') {
|
|
18
32
|
return <img src={src} width={width} height={height} title={title} alt={alt} loading={lazy ? 'lazy' : 'eager'} />;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
interface
|
|
2
|
+
interface CodeProps {
|
|
3
|
+
children?: string[] | string;
|
|
3
4
|
copyButtons?: boolean;
|
|
4
5
|
lang?: string;
|
|
5
6
|
meta?: string;
|
|
6
7
|
theme?: string;
|
|
7
8
|
value?: string;
|
|
8
9
|
}
|
|
9
|
-
declare const Code: (props:
|
|
10
|
+
declare const Code: (props: CodeProps) => React.JSX.Element;
|
|
10
11
|
export default Code;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface EmbedProps {
|
|
3
|
+
lazy?: boolean;
|
|
4
|
+
url: string;
|
|
5
|
+
title: string;
|
|
6
|
+
provider?: string;
|
|
7
|
+
html?: string;
|
|
8
|
+
iframe?: boolean;
|
|
9
|
+
image?: string;
|
|
10
|
+
favicon?: string;
|
|
11
|
+
}
|
|
12
|
+
declare const Embed: ({ lazy, url, provider, title, html, iframe, image, favicon, ...attrs }: EmbedProps) => React.JSX.Element;
|
|
13
|
+
export default Embed;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
2
|
+
interface ImageProps {
|
|
3
3
|
align?: string;
|
|
4
4
|
alt?: string;
|
|
5
5
|
border?: boolean;
|
|
6
|
-
caption
|
|
6
|
+
caption?: string;
|
|
7
7
|
className?: string;
|
|
8
8
|
height?: string;
|
|
9
|
-
src
|
|
9
|
+
src: string;
|
|
10
10
|
title?: string;
|
|
11
11
|
width?: string;
|
|
12
12
|
lazy?: boolean;
|
|
13
|
-
}
|
|
13
|
+
}
|
|
14
|
+
declare const Image: (Props: ImageProps) => React.JSX.Element;
|
|
14
15
|
export default Image;
|
package/dist/enums.d.ts
CHANGED