openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

typescript.html (1557B)


      1 <!doctype html>
      2 
      3 <title>CodeMirror: TypeScript mode</title>
      4 <meta charset="utf-8"/>
      5 <link rel=stylesheet href="../../doc/docs.css">
      6 
      7 <link rel="stylesheet" href="../../lib/codemirror.css">
      8 <script src="../../lib/codemirror.js"></script>
      9 <script src="javascript.js"></script>
     10 <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
     11 <div id=nav>
     12   <a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>
     13 
     14   <ul>
     15     <li><a href="../../index.html">Home</a>
     16     <li><a href="../../doc/manual.html">Manual</a>
     17     <li><a href="https://github.com/codemirror/codemirror">Code</a>
     18   </ul>
     19   <ul>
     20     <li><a href="../index.html">Language modes</a>
     21     <li><a class=active href="#">TypeScript</a>
     22   </ul>
     23 </div>
     24 
     25 <article>
     26 <h2>TypeScript mode</h2>
     27 
     28 
     29 <div><textarea id="code" name="code">
     30 class Greeter {
     31   greeting: string;
     32   constructor (message: string) {
     33     this.greeting = message;
     34   }
     35   greet() {
     36     return "Hello, " + this.greeting;
     37   }
     38 }   
     39 
     40 var greeter = new Greeter("world");
     41 
     42 var button = document.createElement('button')
     43 button.innerText = "Say Hello"
     44 button.onclick = function() {
     45   alert(greeter.greet())
     46 }
     47 
     48 document.body.appendChild(button)
     49 
     50 </textarea></div>
     51 
     52     <script>
     53       var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
     54         lineNumbers: true,
     55         matchBrackets: true,
     56         mode: "text/typescript"
     57       });
     58     </script>
     59 
     60     <p>This is a specialization of the <a href="index.html">JavaScript mode</a>.</p>
     61   </article>