@@ -33,6 +33,7 @@ import { replaceText } from "./utils";
3333import {
3434 CODE_BLOCK_REGEX ,
3535 CODE_BLOCK_TYPE ,
36+ ENTITY_TYPE ,
3637 defaultInlineWhitelist ,
3738 defaultBlockWhitelist ,
3839} from "./constants" ;
@@ -101,13 +102,17 @@ function checkCharacterForState(config, editorState, character) {
101102 editorState === newEditorState &&
102103 config . features . inline . includes ( "IMAGE" )
103104 ) {
104- newEditorState = handleImage ( editorState , character ) ;
105+ newEditorState = handleImage (
106+ editorState ,
107+ character ,
108+ config . entityType . IMAGE
109+ ) ;
105110 }
106111 if (
107112 editorState === newEditorState &&
108113 config . features . inline . includes ( "LINK" )
109114 ) {
110- newEditorState = handleLink ( editorState , character ) ;
115+ newEditorState = handleLink ( editorState , character , config . entityType . LINK ) ;
111116 }
112117 if (
113118 newEditorState === editorState &&
@@ -204,6 +209,7 @@ const defaultConfig = {
204209 inline : defaultInlineWhitelist ,
205210 block : defaultBlockWhitelist ,
206211 } ,
212+ entityType : ENTITY_TYPE ,
207213} ;
208214
209215const createMarkdownPlugin = ( _config = { } ) => {
@@ -216,6 +222,10 @@ const createMarkdownPlugin = (_config = {}) => {
216222 ...defaultConfig . features ,
217223 ..._config . features ,
218224 } ,
225+ entityType : {
226+ ...defaultConfig . entityType ,
227+ ..._config . entityType ,
228+ } ,
219229 } ;
220230
221231 return {
@@ -226,7 +236,14 @@ const createMarkdownPlugin = (_config = {}) => {
226236 wrapper : < pre spellCheck = "false" /> ,
227237 } ,
228238 } ) . merge ( checkboxBlockRenderMap ) ,
229- decorators : [ createLinkDecorator ( ) , createImageDecorator ( ) ] ,
239+ decorators : [
240+ createLinkDecorator ( {
241+ entityType : config . entityType . LINK ,
242+ } ) ,
243+ createImageDecorator ( {
244+ entityType : config . entityType . IMAGE ,
245+ } ) ,
246+ ] ,
230247 initialize ( { setEditorState, getEditorState } ) {
231248 store . setEditorState = setEditorState ;
232249 store . getEditorState = getEditorState ;
0 commit comments