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