You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.5 KiB

5 months ago
  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/5"><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/codemirror5">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>