| 
				
			 | 
			
			
				@@ -0,0 +1,52 @@ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				1
			 | 
			
			
				+import * as React from "react"; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				2
			 | 
			
			
				+import ReactMde from 'react-mde'; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				3
			 | 
			
			
				+import * as Showdown from "showdown"; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				4
			 | 
			
			
				+import 'react-mde/lib/styles/css/react-mde-all.css'; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				5
			 | 
			
			
				+import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				6
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				7
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				8
			 | 
			
			
				+const icons = { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				9
			 | 
			
			
				+    "bold": <FontAwesomeIcon icon="bold" />, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				10
			 | 
			
			
				+    "heading": <FontAwesomeIcon icon="heading" />, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				11
			 | 
			
			
				+    "italic": <FontAwesomeIcon icon="italic" />, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				12
			 | 
			
			
				+    "strikethrough": <FontAwesomeIcon icon="strikethrough" />, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				13
			 | 
			
			
				+    "link": <FontAwesomeIcon icon="link" />, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				14
			 | 
			
			
				+    "quote-right": <FontAwesomeIcon icon="quote-right" />, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				15
			 | 
			
			
				+    "code": <FontAwesomeIcon icon="code" />, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				16
			 | 
			
			
				+    "image": <FontAwesomeIcon icon="image" />, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				17
			 | 
			
			
				+    "list-ul": <FontAwesomeIcon icon="list-ul" />, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				18
			 | 
			
			
				+    "list-ol": <FontAwesomeIcon icon="list-ol" />, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				19
			 | 
			
			
				+    "tasks": <FontAwesomeIcon icon="tasks" />, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				20
			 | 
			
			
				+  }; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				21
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				22
			 | 
			
			
				+  const iconProvider = (name) => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				23
			 | 
			
			
				+    return icons[name] || "❓"; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				24
			 | 
			
			
				+  }; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				25
			 | 
			
			
				+   
			 | 
		
	
		
			
			| 
				
			 | 
			
				26
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				27
			 | 
			
			
				+export default class MarkdownEditor extends React.Component { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				28
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				29
			 | 
			
			
				+    constructor(props) { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				30
			 | 
			
			
				+        super(props); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				31
			 | 
			
			
				+        this.converter = new Showdown.Converter({tables: true, simplifiedAutoLink: true}); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				32
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				33
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				34
			 | 
			
			
				+    handleValueChange = (mdeState) => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				35
			 | 
			
			
				+        this.setState({mdeState}); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				36
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				37
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				38
			 | 
			
			
				+    render() { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				39
			 | 
			
			
				+      const defaultProps = { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				40
			 | 
			
			
				+        layout: 'horizontal', 
			 | 
		
	
		
			
			| 
				
			 | 
			
				41
			 | 
			
			
				+        buttonContentOptions: { iconProvider }, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				42
			 | 
			
			
				+        generateMarkdownPreview: (markdown) => Promise.resolve(this.converter.makeHtml(markdown)), 
			 | 
		
	
		
			
			| 
				
			 | 
			
				43
			 | 
			
			
				+      } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				44
			 | 
			
			
				+      const props=  { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				45
			 | 
			
			
				+        ...this.props, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				46
			 | 
			
			
				+        ...defaultProps, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				47
			 | 
			
			
				+      } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				48
			 | 
			
			
				+        return ( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				49
			 | 
			
			
				+          <ReactMde {...props} /> 
			 | 
		
	
		
			
			| 
				
			 | 
			
				50
			 | 
			
			
				+        ); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				51
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				52
			 | 
			
			
				+} 
			 |