|
|
|
@ -9,7 +9,7 @@ import { existsSync, promises } from 'fs';
|
|
|
|
|
import Markdown from 'react-markdown';
|
|
|
|
|
import gfm from 'remark-gfm';
|
|
|
|
|
|
|
|
|
|
import { CodeBlock, Icon, DeferredRender, Spinner, LazyImageZoomable, Modal, ImageModal, Anchor, ContextMenu, CheckboxItem, Flex } from '.';
|
|
|
|
|
import { CodeBlock, Icon, DeferredRender, Spinner, LazyImageZoomable, Modal, ImageModal, Anchor, ContextMenu, Checkbox, Flex } from '.';
|
|
|
|
|
|
|
|
|
|
const { readFile } = promises;
|
|
|
|
|
const { openContextMenu, closeContextMenu } = contextMenu;
|
|
|
|
@ -127,48 +127,52 @@ export default memo(({ source, type, addonId }) => {
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
li: ({ children, className }) => {
|
|
|
|
|
children.forEach(child => {
|
|
|
|
|
if (child?.props?.type === 'checkbox') {
|
|
|
|
|
children =
|
|
|
|
|
<CheckboxItem className='vz-markdown-checkbox' align={Flex.Align.TOP} value={Boolean(child?.props?.checked)} readOnly={child?.props?.disabled}>
|
|
|
|
|
{children[children.length - 1]}
|
|
|
|
|
</CheckboxItem>;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return (
|
|
|
|
|
<li className={joinClassNames('vz-markdown-li', className)}>
|
|
|
|
|
{children}
|
|
|
|
|
</li>
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
input: ({ children, checked, disabled, type }) => (
|
|
|
|
|
type === 'checkbox'
|
|
|
|
|
? (
|
|
|
|
|
<Checkbox className='vz-markdown-checkbox' align={Flex.Align.TOP} value={!!checked} readOnly={disabled}>
|
|
|
|
|
{children && children}
|
|
|
|
|
</Checkbox>
|
|
|
|
|
)
|
|
|
|
|
: (
|
|
|
|
|
<input type={type} checked={checked} disabled={disabled} />
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
a: ({ href, children }) => {
|
|
|
|
|
return <>
|
|
|
|
|
<Anchor
|
|
|
|
|
href={href}
|
|
|
|
|
className={joinClassNames('vz-markdown-link', anchor, anchorUnderlineOnHover)}
|
|
|
|
|
>
|
|
|
|
|
{children}
|
|
|
|
|
</Anchor>
|
|
|
|
|
</>;
|
|
|
|
|
},
|
|
|
|
|
li: ({ children, className }) => (
|
|
|
|
|
<li className={joinClassNames('vz-markdown-li', className)}>
|
|
|
|
|
{children}
|
|
|
|
|
</li>
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
em: ({ children }) => {
|
|
|
|
|
return <em className='vz-markdown-em'>{children}</em>;
|
|
|
|
|
},
|
|
|
|
|
a: ({ href, children }) => (
|
|
|
|
|
<Anchor
|
|
|
|
|
href={href}
|
|
|
|
|
className={joinClassNames('vz-markdown-link', anchor, anchorUnderlineOnHover)}
|
|
|
|
|
>
|
|
|
|
|
{children}
|
|
|
|
|
</Anchor>
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
strong: ({ children }) => {
|
|
|
|
|
return <strong className='vz-markdown-strong'>{children}</strong>;
|
|
|
|
|
},
|
|
|
|
|
em: ({ children }) => (
|
|
|
|
|
<em className='vz-markdown-em'>
|
|
|
|
|
{children}
|
|
|
|
|
</em>
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
blockquote: ({ children }) => {
|
|
|
|
|
return <blockquote className='vz-markdown-blockquote'>{children}</blockquote>;
|
|
|
|
|
},
|
|
|
|
|
strong: ({ children }) => (
|
|
|
|
|
<strong className='vz-markdown-strong'>
|
|
|
|
|
{children}
|
|
|
|
|
</strong>
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
hr: () => {
|
|
|
|
|
return <hr className='vz-markdown-hr' />;
|
|
|
|
|
},
|
|
|
|
|
blockquote: ({ children }) => (
|
|
|
|
|
<blockquote className='vz-markdown-blockquote'>
|
|
|
|
|
{children}
|
|
|
|
|
</blockquote>
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
hr: () => <hr className='vz-markdown-hr' />,
|
|
|
|
|
|
|
|
|
|
code: ({ inline, className, children }) => {
|
|
|
|
|
const language = className?.match(/(language-)/)?.input?.replace('language-', '');
|
|
|
|
|