Skip to content

Commit

Permalink
feat: add warpperElement props.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed May 4, 2021
1 parent 5f54455 commit 214ad1b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -46,6 +46,7 @@ type MarkdownPreviewProps = {
className?: string;
source?: string;
style?: React.CSSProperties;
warpperElement?: HTMLDivElement;
onScroll?: (e: React.UIEvent<HTMLDivElement>) => void;
onMouseOver?: (e: React.MouseEvent<HTMLDivElement>) => void;
} & ReactMarkdownProps;
Expand Down
5 changes: 3 additions & 2 deletions src/index.tsx
Expand Up @@ -13,6 +13,7 @@ export type MarkdownPreviewProps = {
className?: string;
source?: string;
style?: React.CSSProperties;
warpperElement?: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
onScroll?: (e: React.UIEvent<HTMLDivElement>) => void;
onMouseOver?: (e: React.MouseEvent<HTMLDivElement>) => void;
} & Omit<ReactMarkdown.ReactMarkdownOptions, 'children'>;
Expand All @@ -23,7 +24,7 @@ export type MarkdownPreviewRef = {
} & MarkdownPreviewProps;

export default React.forwardRef<MarkdownPreviewRef, MarkdownPreviewProps>((props, ref) => {
const { className, source, style, onScroll, onMouseOver, ...other } = props || {};
const { className, source, style, onScroll, onMouseOver, warpperElement = {}, ...other } = props || {};
const mdp = React.createRef<HTMLDivElement>();
const loadedLang = React.useRef<string[]>(['markup']);
useEffect(() => {
Expand Down Expand Up @@ -53,7 +54,7 @@ export default React.forwardRef<MarkdownPreviewRef, MarkdownPreviewProps>((props

const cls = `wmde-markdown wmde-markdown-color ${className || ''}`;
return (
<div ref={mdp} onScroll={onScroll} onMouseOver={onMouseOver} className={cls} style={style}>
<div ref={mdp} onScroll={onScroll} onMouseOver={onMouseOver} {...warpperElement} className={cls} style={style}>
<ReactMarkdown
{...other}
plugins={[gfm, ...(other.plugins || [])]}
Expand Down

0 comments on commit 214ad1b

Please sign in to comment.