Cleaning
This commit is contained in:
		
							parent
							
								
									c4c2c54d23
								
							
						
					
					
						commit
						f72b7f2f56
					
				| 
						 | 
				
			
			@ -28,7 +28,8 @@
 | 
			
		|||
 | 
			
		||||
  onMount(async () => {
 | 
			
		||||
    let lang = getLangFromUrl()
 | 
			
		||||
    lang = lang === 'mrwn' || lang === 'gflm' ? 'md' : lang // back compatiblity with old links
 | 
			
		||||
    // Remove github flavored markdown, redundant with markdown
 | 
			
		||||
    lang = lang === 'gflm' ? 'md' : lang
 | 
			
		||||
 | 
			
		||||
    // extract the part in the url after the hash
 | 
			
		||||
    const hash = window.location.hash.slice(1)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,7 +18,8 @@
 | 
			
		|||
    if (editor) {
 | 
			
		||||
      const url = new URL(window.location.origin)
 | 
			
		||||
      compressed = await brotli.compress(editor.getValue())
 | 
			
		||||
      if ($selectedLang) {
 | 
			
		||||
      // Set the language (ignore for plain text, since it's the default)
 | 
			
		||||
      if ($selectedLang && $selectedLang !== 'plt') {
 | 
			
		||||
        url.searchParams.set('l', $selectedLang)
 | 
			
		||||
      }
 | 
			
		||||
      url.hash = compressed
 | 
			
		||||
| 
						 | 
				
			
			@ -32,6 +33,8 @@
 | 
			
		|||
  }, 1000)
 | 
			
		||||
 | 
			
		||||
  async function initCodeEditor() {
 | 
			
		||||
    $selectedLang = new URLSearchParams(window.location.search).get('l') ?? ' plt'
 | 
			
		||||
 | 
			
		||||
    CodeMirror.modeURL = 'https://cdn.jsdelivr.net/npm/codemirror@5.65.16/mode/%N/%N.js'
 | 
			
		||||
    editor = new CodeMirror(byId('editor'), {
 | 
			
		||||
      lineNumbers: true,
 | 
			
		||||
| 
						 | 
				
			
			@ -64,7 +67,6 @@
 | 
			
		|||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    $selectedLang = new URLSearchParams(window.location.search).get('l') ?? ' plt'
 | 
			
		||||
  }
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user