Skip to content

Commit 12a17e2

Browse files
committed
type: Fix type errors.
1 parent 68c2851 commit 12a17e2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import gfm from 'remark-gfm';
44
import slug from 'rehype-slug';
55
import headings from 'rehype-autolink-headings'
66
import rehypeRaw from 'rehype-raw';
7+
// @ts-ignore
78
import rehypePrism from '@mapbox/rehype-prism';
89
import rehypeRewrite from 'rehype-rewrite';
910
import './styles/markdown.less';
1011
import './styles/markdowncolor.less';
1112

1213
const rehypeRewriteHandle = (node: any, index: number, parent: any) => {
13-
if (node.type === 'element' && parent.type === 'root' && /h(1|2|3|4|5|6)/.test(node.tagName) && index !== 0) {
14-
const child = node.children && node.children[0] ? node.children[0] : null;
14+
if (node.type === 'element' && parent.type === 'root' && /h(1|2|3|4|5|6)/.test(node.tagName)) {
15+
const child = node.children && node.children[0];
1516
if (child && child.properties && child.properties.ariaHidden === 'true') {
1617
child.properties = { class: 'anchor', ...child.properties };
1718
child.children = [
@@ -57,7 +58,7 @@ export type MarkdownPreviewRef = {
5758
} & MarkdownPreviewProps;
5859

5960
export default React.forwardRef<MarkdownPreviewRef, MarkdownPreviewProps>((props, ref) => {
60-
const { prefixCls = 'wmde-markdown wmde-markdown-color', className, source, style, onScroll, onMouseOver, warpperElement = {}, ...other } = props || {};
61+
const { prefixCls = 'wmde-markdown wmde-markdown-color', className, source, style, onScroll, onMouseOver, warpperElement = {}, ...other } = props;
6162
const mdp = React.createRef<HTMLDivElement>();
6263
useImperativeHandle(ref, () => ({ ...props, mdp }), [mdp, props]);
6364
const cls = `${prefixCls || ''} ${className || ''}`;

0 commit comments

Comments
 (0)