@@ -287,6 +287,19 @@ export default class CodeEditor extends React.Component {
287287 const matcher = / ^ (?: \w + : ) ? \/ \/ ( [ ^ \s \. ] + \. \S { 2 } | l o c a l h o s t [ \: ? \d ] * ) \S * $ /
288288 return matcher . test ( str )
289289 }
290+ const isInLinkTag = ( editor ) => {
291+ const startCursor = editor . getCursor ( 'start' )
292+ const prevChar = editor . getRange (
293+ { line : startCursor . line , ch : startCursor . ch - 2 } ,
294+ { line : startCursor . line , ch : startCursor . ch }
295+ )
296+ const endCursor = editor . getCursor ( 'end' )
297+ const nextChar = editor . getRange (
298+ { line : endCursor . line , ch : endCursor . ch } ,
299+ { line : endCursor . line , ch : endCursor . ch + 1 }
300+ )
301+ return prevChar === '](' && nextChar === ')'
302+ }
290303 if ( dataTransferItem . type . match ( 'image' ) ) {
291304 const blob = dataTransferItem . getAsFile ( )
292305 const reader = new FileReader ( )
@@ -306,7 +319,7 @@ export default class CodeEditor extends React.Component {
306319 const imageMd = ` } )`
307320 this . insertImageMd ( imageMd )
308321 }
309- } else if ( this . props . fetchUrlTitle && isURL ( pastedTxt ) ) {
322+ } else if ( this . props . fetchUrlTitle && isURL ( pastedTxt ) && ! isInLinkTag ( editor ) ) {
310323 this . handlePasteUrl ( e , editor , pastedTxt )
311324 }
312325 }
0 commit comments