enterkey.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <!--
  3. Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
  4. For licensing, see LICENSE.html or http://ckeditor.com/license
  5. -->
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7. <head>
  8. <title>ENTER Key Configuration &mdash; CKEditor Sample</title>
  9. <meta content="text/html; charset=utf-8" http-equiv="content-type" />
  10. <script type="text/javascript" src="../ckeditor.js"></script>
  11. <script src="sample.js" type="text/javascript"></script>
  12. <link href="sample.css" rel="stylesheet" type="text/css" />
  13. <script type="text/javascript">
  14. //<![CDATA[
  15. var editor;
  16. function changeEnter()
  17. {
  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. {
  24. enterMode : Number( document.getElementById( 'xEnter' ).value ),
  25. shiftEnterMode : Number( document.getElementById( 'xShiftEnter' ).value )
  26. });
  27. }
  28. window.onload = changeEnter;
  29. //]]>
  30. </script>
  31. </head>
  32. <body>
  33. <h1 class="samples">
  34. CKEditor Sample &mdash; ENTER Key Configuration
  35. </h1>
  36. <div class="description">
  37. <p>
  38. This sample shows how to configure the <em>Enter</em> and <em>Shift+Enter</em> keys
  39. to perform actions specified in the
  40. <a class="samples" href="http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.enterMode"><code>enterMode</code></a>
  41. and <a class="samples" href="http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html#.shiftEnterMode"><code>shiftEnterMode</code></a>
  42. parameters, respectively.
  43. You can choose from the following options:
  44. </p>
  45. <ul class="samples">
  46. <li><strong><code>ENTER_P</code></strong> &ndash; new <code>&lt;p&gt;</code> paragraphs are created;</li>
  47. <li><strong><code>ENTER_BR</code></strong> &ndash; lines are broken with <code>&lt;br&gt;</code> elements;</li>
  48. <li><strong><code>ENTER_DIV</code></strong> &ndash; new <code>&lt;div&gt;</code> blocks are created.</li>
  49. </ul>
  50. <p>
  51. 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.
  52. </p>
  53. <pre class="samples">CKEDITOR.replace( '<em>textarea_id</em>',
  54. {
  55. <strong>enterMode : CKEDITOR.ENTER_DIV</strong>
  56. });</pre>
  57. <p>
  58. Note that <code><em>textarea_id</em></code> in the code above is the <code>id</code> attribute of
  59. the <code>&lt;textarea&gt;</code> element to be replaced.
  60. </p>
  61. </div>
  62. <!-- This <div> holds alert messages to be display in the sample page. -->
  63. <div id="alerts">
  64. <noscript>
  65. <p>
  66. <strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript
  67. support, like yours, you should still see the contents (HTML data) and you should
  68. be able to edit it normally, without a rich editor interface.
  69. </p>
  70. </noscript>
  71. </div>
  72. <div style="float: left; margin-right: 20px">
  73. When <em>Enter</em> is pressed:<br />
  74. <select id="xEnter" onchange="changeEnter();">
  75. <option selected="selected" value="1">Create a new &lt;P&gt; (recommended)</option>
  76. <option value="3">Create a new &lt;DIV&gt;</option>
  77. <option value="2">Break the line with a &lt;BR&gt;</option>
  78. </select>
  79. </div>
  80. <div style="float: left">
  81. When <em>Shift+Enter</em> is pressed:<br />
  82. <select id="xShiftEnter" onchange="changeEnter();">
  83. <option value="1">Create a new &lt;P&gt;</option>
  84. <option value="3">Create a new &lt;DIV&gt;</option>
  85. <option selected="selected" value="2">Break the line with a &lt;BR&gt; (recommended)</option>
  86. </select>
  87. </div>
  88. <br style="clear: both" />
  89. <form action="sample_posteddata.php" method="post">
  90. <p>
  91. <br />
  92. <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>
  93. </p>
  94. <p>
  95. <input type="submit" value="Submit" />
  96. </p>
  97. </form>
  98. <div id="footer">
  99. <hr />
  100. <p>
  101. CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
  102. </p>
  103. <p id="copy">
  104. Copyright &copy; 2003-2011, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
  105. Knabben. All rights reserved.
  106. </p>
  107. </div>
  108. </body>
  109. </html>