@@ -31,6 +31,15 @@ describe('paste-markdown', function () {
3131 assert . equal ( textarea . value , 'The examples can be found [here](https://github.com).' )
3232 } )
3333
34+ it ( 'does not turn pasted urls on selected text into markdown links if skip formatting' , function ( ) {
35+ // eslint-disable-next-line i18n-text/no-en
36+ textarea . value = 'The examples can be found here.'
37+ textarea . addEventListener ( 'keydown' , skipFormatting ( textarea ) )
38+ textarea . setSelectionRange ( 26 , 30 )
39+ paste ( textarea , { 'text/plain' : 'https://github.com' } )
40+ assert . equal ( textarea . value , 'The examples can be found here.' )
41+ } )
42+
3443 it ( "doesn't paste a markdown URL when pasting over a selected URL" , function ( ) {
3544 // eslint-disable-next-line i18n-text/no-en
3645 textarea . value = 'The examples can be found here: https://docs.github.com'
@@ -119,17 +128,6 @@ describe('paste-markdown', function () {
119128 assert . include ( textarea . value , '# hello' )
120129 } )
121130
122- it ( 'turns one html link into a markdown link' , function ( ) {
123- // eslint-disable-next-line github/unescaped-html-literal
124- const link = `<meta charset='utf-8'><meta charset="utf-8">
125- <b><a href="https://github.com/" style="text-decoration:none;"><span>link</span></a></b>`
126- const plaintextLink = 'link'
127- const markdownLink = '[link](https://github.com/)'
128-
129- paste ( textarea , { 'text/html' : link , 'text/plain' : plaintextLink } )
130- assert . equal ( textarea . value , markdownLink )
131- } )
132-
133131 it ( 'turns mixed html content containing several links into appropriate markdown' , function ( ) {
134132 // eslint-disable-next-line github/unescaped-html-literal
135133 const sentence = `<meta charset='utf-8'>
@@ -227,6 +225,18 @@ function paste(textarea, data) {
227225 textarea . dispatchEvent ( event )
228226}
229227
228+ function skipFormatting ( textarea ) {
229+ textarea . dispatchEvent (
230+ new KeyboardEvent ( 'keydown' , {
231+ key : 'v' ,
232+ code : 'KeyV' ,
233+ shiftKey : true ,
234+ ctrlKey : true ,
235+ metaKey : true
236+ } )
237+ )
238+ }
239+
230240function wait ( ms ) {
231241 return new Promise ( resolve => setTimeout ( resolve , ms ) )
232242}
0 commit comments