Skip to content

Instantly share code, notes, and snippets.

@etienne-dldc
Last active February 17, 2021 20:13
Show Gist options
  • Save etienne-dldc/29731bda02649bf5beaa5901384950d8 to your computer and use it in GitHub Desktop.
Save etienne-dldc/29731bda02649bf5beaa5901384950d8 to your computer and use it in GitHub Desktop.
Codepad
// enter this in your browser then add it as favorite !
data:text/html,<!DOCTYPE html><html lang="en"> <head> <meta charset="UTF-8"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"/><meta http-equiv="X-UA-Compatible" content="ie=edge"/><style>html, body{font-family: 'Fira Code', monospace; margin: 0;} %23container{position: fixed; top: 0; bottom: 0; left: 0; right: 0;}</style> <title>Codepad</title> </head> <body> <div id="container"></div><script src="https://unpkg.com/monaco-editor@0.15.6/min/vs/loader.js"></script> <script>require.config({paths:{vs: 'https://unpkg.com/monaco-editor@0.15.6/min/vs'}}); require(['vs/editor/editor.main'], function(){function isApplePlatform(){return window && window.navigator && window.navigator.platform ? window.navigator.platform.match(/(Mac|iPhone|iPod|iPad)/i) ? true : false : true;}console.log(monaco.languages.typescript); monaco.languages.typescript.typescriptDefaults.setCompilerOptions({jsx: 'react',}); const fileContent=['function x(){', '\tconsole.log("Hello world!");', '}'].join('\n'); var editor=monaco.editor.create(document.getElementById('container'),{value: fileContent, language: 'typescript', fontFamily: 'Fira Code', fontLigatures: true, theme: 'vs-dark', model: monaco.editor.createModel( fileContent, 'typescript', isApplePlatform() ? new monaco.Uri.file('./editor_name.tsx') : new monaco.Uri('./editor_name.tsx') ),});}); </script> </body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment