@readme/markdown 6.75.0-beta.32 → 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.
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
 
3
3
  interface Props extends React.PropsWithChildren<React.HTMLAttributes<HTMLQuoteElement>> {
4
- attributes: {};
4
+ attributes?: {};
5
5
  icon: string;
6
6
  theme?: string;
7
7
  heading?: React.ReactElement;
@@ -8,14 +8,12 @@ let syntaxHighlighter;
8
8
  let canonicalLanguage = _ => '';
9
9
 
10
10
  if (typeof window !== 'undefined') {
11
- const module = await import('@readme/syntax-highlighter');
12
-
13
- syntaxHighlighter = module.default;
14
- canonicalLanguage = module.canonical;
11
+ import('@readme/syntax-highlighter').then(module => {
12
+ syntaxHighlighter = module.default;
13
+ canonicalLanguage = module.canonical;
14
+ });
15
15
  }
16
16
 
17
- console.log(syntaxHighlighter);
18
-
19
17
  function CopyCode({ codeRef, rootClass = 'rdmd-code-copy', className = '' }) {
20
18
  const copyClass = `${rootClass}_copied`;
21
19
  const button = createRef<HTMLButtonElement>();
@@ -34,7 +32,8 @@ function CopyCode({ codeRef, rootClass = 'rdmd-code-copy', className = '' }) {
34
32
  return <button ref={button} aria-label="Copy Code" className={`${rootClass} ${className}`} onClick={copier} />;
35
33
  }
36
34
 
37
- interface Props extends Omit<HTMLElement, 'lang'> {
35
+ interface CodeProps {
36
+ children?: string[] | string;
38
37
  copyButtons?: boolean;
39
38
  lang?: string;
40
39
  meta?: string;
@@ -42,7 +41,7 @@ interface Props extends Omit<HTMLElement, 'lang'> {
42
41
  value?: string;
43
42
  }
44
43
 
45
- const Code = (props: Props) => {
44
+ const Code = (props: CodeProps) => {
46
45
  const { children, copyButtons, lang, theme, value } = props;
47
46
 
48
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
- const Image = ({
4
- align = '',
5
- alt = '',
6
- border = false,
7
- caption,
8
- className = '',
9
- height = 'auto',
10
- src = '',
11
- title = '',
12
- width = 'auto',
13
- lazy = false,
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,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  interface Props extends React.PropsWithChildren<React.HTMLAttributes<HTMLQuoteElement>> {
3
- attributes: {};
3
+ attributes?: {};
4
4
  icon: string;
5
5
  theme?: string;
6
6
  heading?: React.ReactElement;
@@ -1,10 +1,11 @@
1
1
  import React from 'react';
2
- interface Props extends Omit<HTMLElement, 'lang'> {
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: Props) => React.JSX.Element;
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
- declare const Image: ({ align, alt, border, caption, className, height, src, title, width, lazy, }: {
2
+ interface ImageProps {
3
3
  align?: string;
4
4
  alt?: string;
5
5
  border?: boolean;
6
- caption: any;
6
+ caption?: string;
7
7
  className?: string;
8
8
  height?: string;
9
- src?: string;
9
+ src: string;
10
10
  title?: string;
11
11
  width?: string;
12
12
  lazy?: boolean;
13
- }) => React.JSX.Element;
13
+ }
14
+ declare const Image: (Props: ImageProps) => React.JSX.Element;
14
15
  export default Image;
package/dist/enums.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  export declare enum NodeTypes {
2
- callout = "callout",
2
+ callout = "rdme-callout",
3
3
  codeTabs = "code-tabs",
4
4
  emoji = "emoji",
5
5
  i = "i",
6
6
  image = "image",
7
- htmlBlock = "html-block"
7
+ htmlBlock = "html-block",
8
+ embed = "rdme-embed"
8
9
  }