@readme/markdown 6.75.0-beta.31 → 6.75.0-beta.32

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.
@@ -3,12 +3,29 @@ import * as React from 'react';
3
3
  interface Props extends React.PropsWithChildren<React.HTMLAttributes<HTMLQuoteElement>> {
4
4
  attributes: {};
5
5
  icon: string;
6
- theme: string;
6
+ theme?: string;
7
7
  heading?: React.ReactElement;
8
8
  }
9
9
 
10
+ const themes: Record<string, string> = {
11
+ '\uD83D\uDCD8': 'info',
12
+ '\uD83D\uDEA7': 'warn',
13
+ '\u26A0\uFE0F': 'warn',
14
+ '\uD83D\uDC4D': 'okay',
15
+ '\u2705': 'okay',
16
+ '\u2757\uFE0F': 'error',
17
+ '\u2757': 'error',
18
+ '\uD83D\uDED1': 'error',
19
+ '\u2049\uFE0F': 'error',
20
+ '\u203C\uFE0F': 'error',
21
+ '\u2139\uFE0F': 'info',
22
+ '\u26A0': 'warn',
23
+ };
24
+
10
25
  const Callout = (props: Props) => {
11
- const { attributes, children, theme, icon, heading } = props;
26
+ const { attributes, children, icon, heading } = props;
27
+
28
+ let theme = props.theme || themes[icon] || 'default';
12
29
 
13
30
  return (
14
31
  // @ts-ignore
@@ -6,13 +6,16 @@ import React, { createRef } from 'react';
6
6
  // https://github.com/codemirror/CodeMirror/issues/3701#issuecomment-164904534
7
7
  let syntaxHighlighter;
8
8
  let canonicalLanguage = _ => '';
9
+
9
10
  if (typeof window !== 'undefined') {
10
- // eslint-disable-next-line global-require
11
- syntaxHighlighter = require('@readme/syntax-highlighter').default;
12
- // eslint-disable-next-line global-require
13
- ({ canonical: canonicalLanguage } = require('@readme/syntax-highlighter'));
11
+ const module = await import('@readme/syntax-highlighter');
12
+
13
+ syntaxHighlighter = module.default;
14
+ canonicalLanguage = module.canonical;
14
15
  }
15
16
 
17
+ console.log(syntaxHighlighter);
18
+
16
19
  function CopyCode({ codeRef, rootClass = 'rdmd-code-copy', className = '' }) {
17
20
  const copyClass = `${rootClass}_copied`;
18
21
  const button = createRef<HTMLButtonElement>();
@@ -52,7 +55,7 @@ const Code = (props: Props) => {
52
55
  dark: theme === 'dark',
53
56
  };
54
57
 
55
- const code = value ?? children?.[0] ?? children ?? '';
58
+ const code = value ?? (Array.isArray(children) ? children[0] : children) ?? '';
56
59
  const highlightedCode = syntaxHighlighter && code ? syntaxHighlighter(code, language, codeOpts) : code;
57
60
 
58
61
  return (
@@ -2,7 +2,7 @@ import * as React from 'react';
2
2
  interface Props extends React.PropsWithChildren<React.HTMLAttributes<HTMLQuoteElement>> {
3
3
  attributes: {};
4
4
  icon: string;
5
- theme: string;
5
+ theme?: string;
6
6
  heading?: React.ReactElement;
7
7
  }
8
8
  declare const Callout: (props: Props) => React.JSX.Element;
package/dist/enums.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export declare enum NodeTypes {
2
+ callout = "callout",
2
3
  codeTabs = "code-tabs",
3
4
  emoji = "emoji",
4
5
  i = "i",
@@ -1,3 +1,4 @@
1
1
  import React from 'react';
2
+ import './demo.scss';
2
3
  declare const App: () => React.JSX.Element;
3
4
  export default App;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
2
  import { RunOptions } from '@mdx-js/mdx';
3
3
  import * as Components from './components';
4
+ type ComponentOpts = Record<string, (props: any) => React.ReactNode>;
4
5
  type RunOpts = Omit<RunOptions, 'Fragment'> & {
5
- components?: Record<string, () => React.ReactNode>;
6
+ components?: ComponentOpts;
6
7
  imports?: Record<string, unknown>;
7
8
  };
8
9
  export { Components };