Changeset 6144


Ignore:
Timestamp:
12/01/10 11:02:37 (4 years ago)
Author:
garry.yao
Message:

Update api.html sample page for demonstrating the newly introduced editor::insertText method.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CKEditor/branches/versions/3.5.x/_samples/api.html

    r6050 r6144  
    3333        // Get the editor instance that we want to interact with. 
    3434        var oEditor = CKEDITOR.instances.editor1; 
    35         var value = document.getElementById( 'plainArea' ).value; 
     35        var value = document.getElementById( 'htmlArea' ).value; 
    3636 
    3737        // Check the active editing mode. 
     
    4545} 
    4646 
     47function InsertText() 
     48{ 
     49        // Get the editor instance that we want to interact with. 
     50        var oEditor = CKEDITOR.instances.editor1; 
     51        var value = document.getElementById( 'txtArea' ).value; 
     52 
     53        // Check the active editing mode. 
     54        if ( oEditor.mode == 'wysiwyg' ) 
     55        { 
     56                // Insert as plain text. 
     57                oEditor.insertText( value ); 
     58        } 
     59        else 
     60                alert( 'You must be on WYSIWYG mode!' ); 
     61} 
     62 
    4763function SetContents() 
    4864{ 
    4965        // Get the editor instance that we want to interact with. 
    5066        var oEditor = CKEDITOR.instances.editor1; 
    51         var value = document.getElementById( 'plainArea' ).value; 
     67        var value = document.getElementById( 'htmlArea' ).value; 
    5268 
    5369        // Set the editor contents (replace the actual one). 
     
    132148                        <input onclick="GetContents();" type="button" value="Get Editor Contents (XHTML)" /> 
    133149                        <br /> 
    134                         <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> 
     150                        <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> 
    135151                        <br /> 
     152                        <br /> 
     153                        <input onclick="InsertText();" type="button" value="Insert Text" /> 
     154                        <br /> 
     155                        <textarea cols="80" id="txtArea" rows="3">   First line with some leading whitespaces. 
     156 
     157Second line of text preceding by two line-breaks.</textarea> 
    136158                        <br /> 
    137159                        <input onclick="ExecuteCommand('bold');" type="button" value="Execute &quot;bold&quot; Command" /> 
Note: See TracChangeset for help on using the changeset viewer.
© 2003 – 2012 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy