JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.5
[ckeditor.git] / _samples / api.html
index 05f5b46..92a9e9d 100644 (file)
@@ -28,7 +28,7 @@ function InsertHTML()
 {\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
@@ -40,11 +40,27 @@ function InsertHTML()
                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
@@ -127,9 +143,15 @@ function ResetDirty()
                        <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">&lt;h2&gt;Test&lt;/h2&gt;&lt;p&gt;This is some &lt;a href="/Test1.html"&gt;sample&lt;/a&gt; HTML&lt;/p&gt;</textarea>\r
+                       <textarea cols="80" id="htmlArea" rows="3">&lt;h2&gt;Test&lt;/h2&gt;&lt;p&gt;This is some &lt;a href="/Test1.html"&gt;sample&lt;/a&gt; HTML&lt;/p&gt;</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 &quot;bold&quot; Command" />\r
                        <input onclick="ExecuteCommand('link');" type="button" value="Execute &quot;link&quot; Command" />\r
                        <br />\r