export function escapeTabsAndNewLines ( str ) { return str . replace ( /\n/g , "\\n" ) . replace ( /\t/g , "\\t" ) ; } export function unescapeTabsAndNewLines ( str ) { return str . replace ( /\\n/g , "\n" ) . replace ( /\\t/g , "\t" ) ; } export function escapeBrackets ( str ) { return str . replace ( /\(/g , escape ) . replace ( /\)/g , escape ) . replace ( /\[/g , escape ) . replace ( /\]/g , escape ) ; } export function copyToClipboard ( template , tab ) { console . log ( "copyToClipboard" , template , tab . title , tab . url ) ; const title = tab . title ; const url = escapeBrackets ( tab . url ) ; const el = document . getElementById ( "dummy" ) as HTMLTextAreaElement ; const textToCopy = template . replace ( "${title}" , title ) . replace ( "${url}" , url ) ; el . value = textToCopy ; el . select ( ) ; document . execCommand ( "copy" ) ; console . log ( "Successfully copied to clipboard: " + textToCopy ) ; }