@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.
- package/components/Callout/index.tsx +19 -2
- package/components/Code/index.tsx +8 -5
- package/dist/components/Callout/index.d.ts +1 -1
- package/dist/enums.d.ts +1 -0
- package/dist/example/App.d.ts +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/main.js +55114 -56934
- package/dist/main.node.js +53437 -55261
- package/dist/processor/transform/index.d.ts +2 -0
- package/dist/processor/transform/readme-components.d.ts +6 -0
- package/package.json +4 -2
|
@@ -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
|
|
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,
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
|
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
|
|
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
package/dist/example/App.d.ts
CHANGED
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?:
|
|
6
|
+
components?: ComponentOpts;
|
|
6
7
|
imports?: Record<string, unknown>;
|
|
7
8
|
};
|
|
8
9
|
export { Components };
|