enterkey.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <!DOCTYPE html>
  2. <!--
  3. Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
  4. For licensing, see LICENSE.md or http://ckeditor.com/license
  5. -->
  6. <html>
  7. <head>
  8. <meta charset="utf-8">
  9. <title>ENTER Key Configuration &mdash; CKEditor Sample</title>
  10. <script src="../../../ckeditor.js"></script>
  11. <link href="../../../samples/old/sample.css" rel="stylesheet">
  12. <meta name="ckeditor-sample-name" content="Using the &quot;Enter&quot; key in CKEditor">
  13. <meta name="ckeditor-sample-group" content="Advanced Samples">
  14. <meta name="ckeditor-sample-description" content="Configuring the behavior of &lt;em&gt;Enter&lt;/em&gt; and &lt;em&gt;Shift+Enter&lt;/em&gt; keys.">
  15. <script>
  16. var editor;
  17. function changeEnter() {
  18. // If we already have an editor, let's destroy it first.
  19. if ( editor )
  20. editor.destroy( true );
  21. // Create the editor again, with the appropriate settings.
  22. editor = CKEDITOR.replace( 'editor1', {
  23. extraPlugins: 'enterkey',
  24. enterMode: Number( document.getElementById( 'xEnter' ).value ),
  25. shiftEnterMode: Number( document.getElementById( 'xShiftEnter' ).value )
  26. });
  27. }
  28. window.onload = changeEnter;
  29. </script>
  30. </head>
  31. <body>
  32. <h1 class="samples">
  33. <a href="../../../samples/old/index.html">CKEditor Samples</a> &raquo; ENTER Key Configuration
  34. </h1>
  35. <div class="warning deprecated">
  36. This sample is not maintained anymore. Check out its <a href="http://sdk.ckeditor.com/samples/enterkey.html">brand new version in CKEditor SDK</a>.
  37. </div>
  38. <div class="description">
  39. <p>
  40. This sample shows how to configure the <em>Enter</em> and <em>Shift+Enter</em> keys
  41. to perform actions specified in the
  42. <a class="samples" href="http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-enterMode"><code>enterMode</code></a>
  43. and <a class="samples" href="http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-shiftEnterMode"><code>shiftEnterMode</code></a>
  44. parameters, respectively.
  45. You can choose from the following options:
  46. </p>
  47. <ul class="samples">
  48. <li><strong><code>ENTER_P</code></strong> &ndash; new <code>&lt;p&gt;</code> paragraphs are created;</li>
  49. <li><strong><code>ENTER_BR</code></strong> &ndash; lines are broken with <code>&lt;br&gt;</code> elements;</li>
  50. <li><strong><code>ENTER_DIV</code></strong> &ndash; new <code>&lt;div&gt;</code> blocks are created.</li>
  51. </ul>
  52. <p>
  53. The sample code below shows how to configure CKEditor to create a <code>&lt;div&gt;</code> block when <em>Enter</em> key is pressed.
  54. </p>
  55. <pre class="samples">
  56. CKEDITOR.replace( '<em>textarea_id</em>', {
  57. <strong>enterMode: CKEDITOR.ENTER_DIV</strong>
  58. });</pre>
  59. <p>
  60. Note that <code><em>textarea_id</em></code> in the code above is the <code>id</code> attribute of
  61. the <code>&lt;textarea&gt;</code> element to be replaced.
  62. </p>
  63. </div>
  64. <div style="float: left; margin-right: 20px">
  65. When <em>Enter</em> is pressed:<br>
  66. <select id="xEnter" onchange="changeEnter();">
  67. <option selected="selected" value="1">Create a new &lt;P&gt; (recommended)</option>
  68. <option value="3">Create a new &lt;DIV&gt;</option>
  69. <option value="2">Break the line with a &lt;BR&gt;</option>
  70. </select>
  71. </div>
  72. <div style="float: left">
  73. When <em>Shift+Enter</em> is pressed:<br>
  74. <select id="xShiftEnter" onchange="changeEnter();">
  75. <option value="1">Create a new &lt;P&gt;</option>
  76. <option value="3">Create a new &lt;DIV&gt;</option>
  77. <option selected="selected" value="2">Break the line with a &lt;BR&gt; (recommended)</option>
  78. </select>
  79. </div>
  80. <br style="clear: both">
  81. <form action="../../../samples/sample_posteddata.php" method="post">
  82. <p>
  83. <br>
  84. <textarea cols="80" id="editor1" name="editor1" rows="10">This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://ckeditor.com/"&gt;CKEditor&lt;/a&gt;.</textarea>
  85. </p>
  86. <p>
  87. <input type="submit" value="Submit">
  88. </p>
  89. </form>
  90. <div id="footer">
  91. <hr>
  92. <p>
  93. CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
  94. </p>
  95. <p id="copy">
  96. Copyright &copy; 2003-2016, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
  97. Knabben. All rights reserved.
  98. </p>
  99. </div>
  100. </body>
  101. </html>