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