@@ -4,12 +4,14 @@ import { inlineMatchers } from "../constants";
44import insertText from "./insertText" ;
55import { getCurrentLine as getLine } from "../utils" ;
66
7- const handleChange = ( editorState , line , whitelist ) => {
7+ const handleChange = ( editorState , line , whitelist , customInlineMatchers ) => {
88 let newEditorState = editorState ;
9- Object . keys ( inlineMatchers )
9+ const matchers = Object . assign ( { } , inlineMatchers , customInlineMatchers ) ;
10+
11+ Object . keys ( matchers )
1012 . filter ( matcher => whitelist . includes ( matcher ) )
1113 . some ( k => {
12- inlineMatchers [ k ] . some ( re => {
14+ matchers [ k ] . some ( re => {
1315 let matchArr ;
1416 do {
1517 matchArr = re . exec ( line ) ;
@@ -31,19 +33,30 @@ const handleChange = (editorState, line, whitelist) => {
3133const handleInlineStyle = (
3234 whitelist ,
3335 editorStateWithoutCharacter ,
34- character
36+ character ,
37+ customInlineMatchers = { }
3538) => {
3639 const editorState = insertText ( editorStateWithoutCharacter , character ) ;
3740 let selection = editorState . getSelection ( ) ;
3841 let line = getLine ( editorState ) ;
39- let newEditorState = handleChange ( editorState , line , whitelist ) ;
42+ let newEditorState = handleChange (
43+ editorState ,
44+ line ,
45+ whitelist ,
46+ customInlineMatchers
47+ ) ;
4048 let lastEditorState = editorState ;
4149
4250 // Recursively resolve markdown, e.g. _*text*_ should turn into both italic and bold
4351 while ( newEditorState !== lastEditorState ) {
4452 lastEditorState = newEditorState ;
4553 line = getLine ( newEditorState ) ;
46- newEditorState = handleChange ( newEditorState , line , whitelist ) ;
54+ newEditorState = handleChange (
55+ newEditorState ,
56+ line ,
57+ whitelist ,
58+ customInlineMatchers
59+ ) ;
4760 }
4861
4962 if ( newEditorState !== editorState ) {
0 commit comments