blob: ae87568a903f2c88b27ce1c4a8d96756637ba98d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
/**
* External dependencies
*/
import { __ } from '@wordpress/i18n';
import MarkdownIt from 'markdown-it';
import { RawHTML } from '@wordpress/element';
/**
* Module variables
*/
const markdownConverter = new MarkdownIt();
const handleLinkClick = event => {
if ( event.target.nodeName === 'A' ) {
const hasConfirmed = window.confirm(
__( 'Are you sure you wish to leave this page?', 'jetpack' )
);
if ( ! hasConfirmed ) {
event.preventDefault();
}
}
};
export default ( { className, source = '' } ) => (
<RawHTML className={ className } onClick={ handleLinkClick }>
{ source.length ? markdownConverter.render( source ) : '' }
</RawHTML>
);
|