JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-4.0.1_full
[ckeditor.git] / samples / plugins / enterkey / enterkey.html
1 <!DOCTYPE html>\r
2 <!--\r
3 Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.\r
4 For licensing, see LICENSE.html or http://ckeditor.com/license\r
5 -->\r
6 <html>\r
7 <head>\r
8         <title>ENTER Key Configuration &mdash; CKEditor Sample</title>\r
9         <meta charset="utf-8">\r
10         <script src="../../../ckeditor.js"></script>\r
11         <link href="../../../samples/sample.css" rel="stylesheet">\r
12         <meta name="ckeditor-sample-name" content="Using the &quot;Enter&quot; key in CKEditor">\r
13         <meta name="ckeditor-sample-group" content="Advanced Samples">\r
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.">\r
15         <script>\r
16 \r
17                 var editor;\r
18 \r
19                 function changeEnter() {\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                                 extraPlugins: 'enterkey',\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         </script>\r
35 </head>\r
36 <body>\r
37         <h1 class="samples">\r
38                 <a href="../../../samples/index.html">CKEditor Samples</a> &raquo; ENTER Key Configuration\r
39         </h1>\r
40         <div class="description">\r
41                 <p>\r
42                         This sample shows how to configure the <em>Enter</em> and <em>Shift+Enter</em> keys\r
43                         to perform actions specified in the\r
44                         <a class="samples" href="http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-enterMode"><code>enterMode</code></a>\r
45                         and <a class="samples" href="http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-shiftEnterMode"><code>shiftEnterMode</code></a>\r
46                         parameters, respectively.\r
47                         You can choose from the following options:\r
48                 </p>\r
49                 <ul class="samples">\r
50                         <li><strong><code>ENTER_P</code></strong> &ndash; new <code>&lt;p&gt;</code> paragraphs are created;</li>\r
51                         <li><strong><code>ENTER_BR</code></strong> &ndash; lines are broken with <code>&lt;br&gt;</code> elements;</li>\r
52                         <li><strong><code>ENTER_DIV</code></strong> &ndash; new <code>&lt;div&gt;</code> blocks are created.</li>\r
53                 </ul>\r
54                 <p>\r
55                         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
56                 </p>\r
57 <pre class="samples">\r
58 CKEDITOR.replace( '<em>textarea_id</em>', {\r
59         <strong>enterMode: CKEDITOR.ENTER_DIV</strong>\r
60 });</pre>\r
61                 <p>\r
62                         Note that <code><em>textarea_id</em></code> in the code above is the <code>id</code> attribute of\r
63                         the <code>&lt;textarea&gt;</code> element to be replaced.\r
64                 </p>\r
65         </div>\r
66         <div style="float: left; margin-right: 20px">\r
67                 When <em>Enter</em> is pressed:<br>\r
68                 <select id="xEnter" onchange="changeEnter();">\r
69                         <option selected="selected" value="1">Create a new &lt;P&gt; (recommended)</option>\r
70                         <option value="3">Create a new &lt;DIV&gt;</option>\r
71                         <option value="2">Break the line with a &lt;BR&gt;</option>\r
72                 </select>\r
73         </div>\r
74         <div style="float: left">\r
75                 When <em>Shift+Enter</em> is pressed:<br>\r
76                 <select id="xShiftEnter" onchange="changeEnter();">\r
77                         <option value="1">Create a new &lt;P&gt;</option>\r
78                         <option value="3">Create a new &lt;DIV&gt;</option>\r
79                         <option selected="selected" value="2">Break the line with a &lt;BR&gt; (recommended)</option>\r
80                 </select>\r
81         </div>\r
82         <br style="clear: both">\r
83         <form action="../../../samples/sample_posteddata.php" method="post">\r
84                 <p>\r
85                         <br>\r
86                         <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
87                 </p>\r
88                 <p>\r
89                         <input type="submit" value="Submit">\r
90                 </p>\r
91         </form>\r
92         <div id="footer">\r
93                 <hr>\r
94                 <p>\r
95                         CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>\r
96                 </p>\r
97                 <p id="copy">\r
98                         Copyright &copy; 2003-2013, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico\r
99                         Knabben. All rights reserved.\r
100                 </p>\r
101         </div>\r
102 </body>\r
103 </html>\r