{\r
// Get the editor instance that we want to interact with.\r
var oEditor = CKEDITOR.instances.editor1;\r
- var value = document.getElementById( 'plainArea' ).value;\r
+ var value = document.getElementById( 'htmlArea' ).value;\r
\r
// Check the active editing mode.\r
if ( oEditor.mode == 'wysiwyg' )\r
alert( 'You must be on WYSIWYG mode!' );\r
}\r
\r
+function InsertText()\r
+{\r
+ // Get the editor instance that we want to interact with.\r
+ var oEditor = CKEDITOR.instances.editor1;\r
+ var value = document.getElementById( 'txtArea' ).value;\r
+\r
+ // Check the active editing mode.\r
+ if ( oEditor.mode == 'wysiwyg' )\r
+ {\r
+ // Insert as plain text.\r
+ oEditor.insertText( value );\r
+ }\r
+ else\r
+ alert( 'You must be on WYSIWYG mode!' );\r
+}\r
+\r
function SetContents()\r
{\r
// Get the editor instance that we want to interact with.\r
var oEditor = CKEDITOR.instances.editor1;\r
- var value = document.getElementById( 'plainArea' ).value;\r
+ var value = document.getElementById( 'htmlArea' ).value;\r
\r
// Set the editor contents (replace the actual one).\r
oEditor.setData( value );\r
<input onclick="SetContents();" type="button" value="Set Editor Contents" />\r
<input onclick="GetContents();" type="button" value="Get Editor Contents (XHTML)" />\r
<br />\r
- <textarea cols="80" id="plainArea" rows="3"><h2>Test</h2><p>This is some <a href="/Test1.html">sample</a> HTML</p></textarea>\r
+ <textarea cols="80" id="htmlArea" rows="3"><h2>Test</h2><p>This is some <a href="/Test1.html">sample</a> HTML</p></textarea>\r
<br />\r
<br />\r
+ <input onclick="InsertText();" type="button" value="Insert Text" />\r
+ <br />\r
+ <textarea cols="80" id="txtArea" rows="3"> First line with some leading whitespaces.\r
+\r
+Second line of text preceding by two line-breaks.</textarea>\r
+ <br />\r
<input onclick="ExecuteCommand('bold');" type="button" value="Execute "bold" Command" />\r
<input onclick="ExecuteCommand('link');" type="button" value="Execute "link" Command" />\r
<br />\r