@readme/markdown 6.75.0-beta.52 → 6.75.0-beta.54

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.
@@ -13,24 +13,42 @@ interface EmbedProps {
13
13
  lazy?: boolean;
14
14
  url: string;
15
15
  title: string;
16
- provider?: string;
16
+ providerName?: string;
17
+ providerUrl?: string;
17
18
  html?: string;
18
19
  iframe?: boolean;
19
20
  image?: string;
20
21
  favicon?: string;
22
+ typeOfEmbed?: string;
21
23
  }
22
24
 
23
- const Embed = ({ lazy = true, url, provider, title, html, iframe, image, favicon, ...attrs }: EmbedProps) => {
25
+ const Embed = ({
26
+ lazy = true,
27
+ url,
28
+ html,
29
+ providerName,
30
+ providerUrl,
31
+ title,
32
+ iframe,
33
+ image,
34
+ favicon,
35
+ ...attrs
36
+ }: EmbedProps) => {
37
+ if (typeof iframe !== 'boolean') iframe = iframe === 'true';
38
+ if (html === 'false') html = undefined;
39
+
24
40
  if (iframe) {
25
41
  return <iframe {...attrs} src={url} style={{ border: 'none', display: 'flex', margin: 'auto' }} />;
26
42
  }
27
43
 
28
- if (!provider)
29
- provider = new URL(url).hostname
44
+ if (!providerUrl && url)
45
+ providerUrl = new URL(url).hostname
30
46
  .split(/(?:www)?\./)
31
47
  .filter(i => i)
32
48
  .join('.');
33
49
 
50
+ if (!providerName) providerName = providerUrl;
51
+
34
52
  const classes = ['embed', image ? 'embed_hasImg' : ''];
35
53
 
36
54
  return (
@@ -40,13 +58,13 @@ const Embed = ({ lazy = true, url, provider, title, html, iframe, image, favicon
40
58
  ) : (
41
59
  <a className="embed-link" href={url} rel="noopener noreferrer" target="_blank">
42
60
  {!image || <img alt={title} className="embed-img" loading={lazy ? 'lazy' : undefined} src={image} />}
43
- {title ? (
61
+ {title && title !== '@embed' ? (
44
62
  <div className="embed-body">
45
- {!favicon || <Favicon alt={provider} src={favicon} />}
46
- {provider && (
63
+ {!favicon || <Favicon alt={providerName} src={favicon} />}
64
+ {providerUrl && (
47
65
  <small className="embed-provider">
48
- {provider.search(/^@{1}/) < 0 ? (
49
- provider
66
+ {providerUrl.search(/^@{1}/) < 0 ? (
67
+ providerName
50
68
  ) : (
51
69
  <code style={{ fontFamily: 'var(--md-code-font, monospace)' }}>{url}</code>
52
70
  )}
@@ -57,16 +57,16 @@ const Image = (Props: ImageProps) => {
57
57
 
58
58
  if (caption) {
59
59
  return (
60
- <figure>
61
- <span
62
- aria-label={alt}
63
- className={`img lightbox ${lightbox ? 'open' : 'closed'}`}
64
- onClick={toggle}
65
- onKeyDown={handleKeyDown}
66
- role={'button'}
67
- tabIndex={0}
68
- >
69
- <span className="lightbox-inner">
60
+ <span
61
+ aria-label={alt}
62
+ className={`img lightbox ${lightbox ? 'open' : 'closed'}`}
63
+ onClick={toggle}
64
+ onKeyDown={handleKeyDown}
65
+ role={'button'}
66
+ tabIndex={0}
67
+ >
68
+ <span className="lightbox-inner">
69
+ <figure>
70
70
  <img
71
71
  src={src}
72
72
  width={width}
@@ -76,34 +76,36 @@ const Image = (Props: ImageProps) => {
76
76
  alt={alt}
77
77
  loading={lazy ? 'lazy' : 'eager'}
78
78
  />
79
- </span>
79
+ <figcaption>{caption}</figcaption>
80
+ </figure>
80
81
  </span>
81
- <figcaption>{caption}</figcaption>
82
- </figure>
82
+ </span>
83
83
  );
84
84
  }
85
85
 
86
86
  return (
87
- <span
88
- aria-label={alt}
89
- className={`img lightbox ${lightbox ? 'open' : 'closed'}`}
90
- onClick={toggle}
91
- onKeyDown={handleKeyDown}
92
- role={'button'}
93
- tabIndex={0}
94
- >
95
- <span className="lightbox-inner">
96
- <img
97
- src={src}
98
- width={width}
99
- height={height}
100
- title={title}
101
- className={`img img-align-${align} ${border ? 'border' : ''}`}
102
- alt={alt}
103
- loading={lazy ? 'lazy' : 'eager'}
104
- />
87
+ <p>
88
+ <span
89
+ aria-label={alt}
90
+ className={`img lightbox ${lightbox ? 'open' : 'closed'}`}
91
+ onClick={toggle}
92
+ onKeyDown={handleKeyDown}
93
+ role={'button'}
94
+ tabIndex={0}
95
+ >
96
+ <span className="lightbox-inner">
97
+ <img
98
+ src={src}
99
+ width={width}
100
+ height={height}
101
+ title={title}
102
+ className={`img img-align-${align} ${border ? 'border' : ''}`}
103
+ alt={alt}
104
+ loading={lazy ? 'lazy' : 'eager'}
105
+ />
106
+ </span>
105
107
  </span>
106
- </span>
108
+ </p>
107
109
  );
108
110
  };
109
111
 
@@ -3,11 +3,13 @@ interface EmbedProps {
3
3
  lazy?: boolean;
4
4
  url: string;
5
5
  title: string;
6
- provider?: string;
6
+ providerName?: string;
7
+ providerUrl?: string;
7
8
  html?: string;
8
9
  iframe?: boolean;
9
10
  image?: string;
10
11
  favicon?: string;
12
+ typeOfEmbed?: string;
11
13
  }
12
- declare const Embed: ({ lazy, url, provider, title, html, iframe, image, favicon, ...attrs }: EmbedProps) => React.JSX.Element;
14
+ declare const Embed: ({ lazy, url, html, providerName, providerUrl, title, iframe, image, favicon, ...attrs }: EmbedProps) => React.JSX.Element;
13
15
  export default Embed;
package/dist/enums.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  export declare enum NodeTypes {
2
2
  callout = "rdme-callout",
3
3
  codeTabs = "code-tabs",
4
- embed = "embed",
4
+ embedBlock = "embed-block",
5
5
  emoji = "gemoji",
6
6
  glossary = "readme-glossary-item",
7
7
  htmlBlock = "html-block",
8
8
  i = "i",
9
- image = "image",
9
+ imageBlock = "image-block",
10
10
  reusableContent = "reusable-content",
11
11
  tutorialTile = "tutorial-tile",
12
12
  variable = "readme-variable"
package/dist/index.d.ts CHANGED
@@ -1,12 +1,11 @@
1
1
  import * as Components from './components';
2
- import { compile, hast, run, mdast, mdx, plain } from './lib';
3
2
  import './styles/main.scss';
4
3
  declare const utils: {
5
4
  readonly options: any;
6
5
  getHref: any;
7
6
  calloutIcons: {};
8
7
  };
9
- export declare const reactProcessor: (opts?: {}) => import("unified").Processor<import("mdast").Root, import("estree").Program, import("estree").Program, import("estree").Program, string>;
10
8
  export declare const html: (text: string, opts?: {}) => void;
11
9
  export declare const esast: (text: string, opts?: {}) => void;
12
- export { compile, hast, run, mdast, mdx, plain, Components, utils };
10
+ export { compile, hast, hastFromHtml, run, mdast, mdx, plain, remarkPlugins } from './lib';
11
+ export { Components, utils };
@@ -2,4 +2,5 @@ interface Options {
2
2
  components?: Record<string, string>;
3
3
  }
4
4
  declare const hast: (text: string, opts?: Options) => import("hast").Root;
5
+ export declare const hastFromHtml: (html: string) => import("hast").Root;
5
6
  export default hast;
@@ -1,9 +1,9 @@
1
1
  import astProcessor, { MdastOpts, remarkPlugins } from './ast-processor';
2
2
  import compile from './compile';
3
- import hast from './hast';
3
+ import hast, { hastFromHtml } from './hast';
4
4
  import mdast from './mdast';
5
5
  import mdx from './mdx';
6
6
  import plain from './plain';
7
7
  import run from './run';
8
8
  export type { MdastOpts };
9
- export { astProcessor, compile, hast, mdast, mdx, plain, run, remarkPlugins };
9
+ export { astProcessor, compile, hast, hastFromHtml, mdast, mdx, plain, run, remarkPlugins };