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-2010, 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>API usage - CKEditor Sample</title> |
---|
9 | <meta content="text/html; charset=utf-8" http-equiv="content-type" /> |
---|
10 | <!-- CKReleaser %REMOVE_LINE% |
---|
11 | <script type="text/javascript" src="../ckeditor.js"></script> |
---|
12 | CKReleaser %REMOVE_START% --> |
---|
13 | <script type="text/javascript" src="../ckeditor_source.js"></script> |
---|
14 | <!-- CKReleaser %REMOVE_END% --> |
---|
15 | <script src="sample.js" type="text/javascript"></script> |
---|
16 | <link href="sample.css" rel="stylesheet" type="text/css" /> |
---|
17 | <script type="text/javascript"> |
---|
18 | //<![CDATA[ |
---|
19 | |
---|
20 | // The instanceReady event is fired when an instance of CKEditor has finished |
---|
21 | // its initialization. |
---|
22 | CKEDITOR.on( 'instanceReady', function( ev ) |
---|
23 | { |
---|
24 | // Show the editor name and description in the browser status bar. |
---|
25 | document.getElementById( 'eMessage' ).innerHTML = '<p>Instance "' + ev.editor.name + '" loaded.<\/p>'; |
---|
26 | |
---|
27 | // Show this sample buttons. |
---|
28 | document.getElementById( 'eButtons' ).style.visibility = ''; |
---|
29 | }); |
---|
30 | |
---|
31 | function createDiv() |
---|
32 | { |
---|
33 | // Get the editor instance that we want to interact with. |
---|
34 | var oEditor = CKEDITOR.instances.editor1; |
---|
35 | |
---|
36 | // Check the active editing mode. |
---|
37 | if ( oEditor.mode == 'wysiwyg' ) |
---|
38 | { |
---|
39 | var oDiv = oEditor.document.createElement( 'DIV' ) ; |
---|
40 | oDiv.setAttribute("class", "wrapper"); |
---|
41 | oDiv.$.innerHTML = "new div"; |
---|
42 | oEditor.insertElement( oDiv ); |
---|
43 | |
---|
44 | } |
---|
45 | else |
---|
46 | alert( 'You must be on WYSIWYG mode!' ); |
---|
47 | } |
---|
48 | |
---|
49 | //]]> |
---|
50 | </script> |
---|
51 | |
---|
52 | </head> |
---|
53 | <body> |
---|
54 | <h1> |
---|
55 | CKEditor Sample |
---|
56 | </h1> |
---|
57 | <!-- This <div> holds alert messages to be display in the sample page. --> |
---|
58 | <div id="alerts"> |
---|
59 | <noscript> |
---|
60 | <p> |
---|
61 | <strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript |
---|
62 | support, like yours, you should still see the contents (HTML data) and you should |
---|
63 | be able to edit it normally, without a rich editor interface. |
---|
64 | </p> |
---|
65 | </noscript> |
---|
66 | </div> |
---|
67 | <form action="sample_posteddata.php" method="post"> |
---|
68 | <p> |
---|
69 | This sample shows how to use the CKeditor JavaScript API to interact with the editor |
---|
70 | at runtime.</p> |
---|
71 | <textarea cols="80" id="editor1" name="editor1" rows="10"><p>This is some <strong>sample text</strong>. You are using <a href="http://ckeditor.com/">CKEditor</a>.</p></textarea> |
---|
72 | |
---|
73 | <script type="text/javascript"> |
---|
74 | //<![CDATA[ |
---|
75 | // Replace the <textarea id="editor1"> with an CKEditor instance. |
---|
76 | var editor = CKEDITOR.replace( 'editor1' ); |
---|
77 | //]]> |
---|
78 | </script> |
---|
79 | |
---|
80 | <div id="eMessage"> |
---|
81 | </div> |
---|
82 | <div id="eButtons" style="visibility: hidden"> |
---|
83 | <input onclick="createDiv();" type="button" value="Create a div" /> |
---|
84 | </div> |
---|
85 | </form> |
---|
86 | <div id="footer"> |
---|
87 | <hr /> |
---|
88 | <p> |
---|
89 | CKEditor - The text editor for Internet - <a href="http://ckeditor.com/">http://ckeditor.com</a> |
---|
90 | </p> |
---|
91 | <p id="copy"> |
---|
92 | Copyright © 2003-2010, <a href="http://cksource.com/">CKSource</a> - Frederico |
---|
93 | Knabben. All rights reserved. |
---|
94 | </p> |
---|
95 | </div> |
---|
96 | </body> |
---|
97 | </html> |
---|