File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ import React , { useState } from "react" ;
2
+ import { RichTextarea , createRegexRenderer } from "../src" ;
3
+
4
+ export default {
5
+ title : "examples" ,
6
+ } ;
7
+
8
+ const style = { width : "400px" , height : "300px" } ;
9
+
10
+ const regexRenderer = createRegexRenderer ( [
11
+ [
12
+ / h t t p s ? : \/ \/ [ - _ . ! ~ * \' ( ) a - z A - Z 0 - 9 ; \/ ? : \@ & = + \$ , % # ] + / g,
13
+ ( { children, key, value } ) => (
14
+ < a
15
+ key = { key }
16
+ style = { { color : "blue" , textDecoration : "underline" } }
17
+ href = { value }
18
+ target = "_blank"
19
+ >
20
+ { children }
21
+ </ a >
22
+ ) ,
23
+ ] ,
24
+ ] ) ;
25
+
26
+ export const Url = ( ) => {
27
+ const [ text , setText ] = useState (
28
+ `Click this url https://github.com/inokawa/rich-textarea !\n\n`
29
+ ) ;
30
+
31
+ return (
32
+ < div >
33
+ < RichTextarea
34
+ style = { style }
35
+ onChange = { ( e ) => setText ( e . target . value ) }
36
+ value = { text }
37
+ >
38
+ { regexRenderer }
39
+ </ RichTextarea >
40
+ </ div >
41
+ ) ;
42
+ } ;
You can’t perform that action at this time.
0 commit comments