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