enterkey.html 4.4 KB

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