placeholder.html 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <!doctype html>
  2. <title>CodeMirror: Placeholder demo</title>
  3. <meta charset="utf-8"/>
  4. <link rel=stylesheet href="../doc/docs.css">
  5. <link rel="stylesheet" href="../lib/codemirror.css">
  6. <script src="../lib/codemirror.js"></script>
  7. <script src="../addon/display/placeholder.js"></script>
  8. <style>
  9. .CodeMirror { border: 1px solid silver; }
  10. .CodeMirror-empty { outline: 1px solid #c22; }
  11. .CodeMirror-empty.CodeMirror-focused { outline: none; }
  12. .CodeMirror pre.CodeMirror-placeholder { color: #999; }
  13. </style>
  14. <div id=nav>
  15. <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
  16. <ul>
  17. <li><a href="../index.html">Home</a>
  18. <li><a href="../doc/manual.html">Manual</a>
  19. <li><a href="https://github.com/codemirror/codemirror">Code</a>
  20. </ul>
  21. <ul>
  22. <li><a class=active href="#">Placeholder</a>
  23. </ul>
  24. </div>
  25. <article>
  26. <h2>Placeholder demo</h2>
  27. <form><textarea id="code" name="code" placeholder="Code goes here..."></textarea></form>
  28. <p>The <a href="../doc/manual.html#addon_placeholder">placeholder</a>
  29. plug-in adds an option <code>placeholder</code> that can be set to
  30. make text appear in the editor when it is empty and not focused.
  31. If the source textarea has a <code>placeholder</code> attribute,
  32. it will automatically be inherited.</p>
  33. <script>
  34. var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
  35. lineNumbers: true
  36. });
  37. </script>
  38. </article>