annotate sites/all/libraries/ckeditor/_samples/api.html @ 2:b74b41bb73f0

-- Google analytics module
author danieleb <danielebarchiesi@me.com>
date Thu, 22 Aug 2013 17:22:54 +0100
parents ff03f76ab3fe
children
rev   line source
danielebarchiesi@0 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
danielebarchiesi@0 2 <!--
danielebarchiesi@0 3 Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
danielebarchiesi@0 4 For licensing, see LICENSE.html or http://ckeditor.com/license
danielebarchiesi@0 5 -->
danielebarchiesi@0 6 <html xmlns="http://www.w3.org/1999/xhtml">
danielebarchiesi@0 7 <head>
danielebarchiesi@0 8 <title>API Usage &mdash; CKEditor Sample</title>
danielebarchiesi@0 9 <meta content="text/html; charset=utf-8" http-equiv="content-type" />
danielebarchiesi@0 10 <script type="text/javascript" src="../ckeditor.js"></script>
danielebarchiesi@0 11 <script src="sample.js" type="text/javascript"></script>
danielebarchiesi@0 12 <link href="sample.css" rel="stylesheet" type="text/css" />
danielebarchiesi@0 13 <script type="text/javascript">
danielebarchiesi@0 14 //<![CDATA[
danielebarchiesi@0 15
danielebarchiesi@0 16 // The instanceReady event is fired, when an instance of CKEditor has finished
danielebarchiesi@0 17 // its initialization.
danielebarchiesi@0 18 CKEDITOR.on( 'instanceReady', function( ev )
danielebarchiesi@0 19 {
danielebarchiesi@0 20 // Show the editor name and description in the browser status bar.
danielebarchiesi@0 21 document.getElementById( 'eMessage' ).innerHTML = '<p>Instance <code>' + ev.editor.name + '<\/code> loaded.<\/p>';
danielebarchiesi@0 22
danielebarchiesi@0 23 // Show this sample buttons.
danielebarchiesi@0 24 document.getElementById( 'eButtons' ).style.display = 'block';
danielebarchiesi@0 25 });
danielebarchiesi@0 26
danielebarchiesi@0 27 function InsertHTML()
danielebarchiesi@0 28 {
danielebarchiesi@0 29 // Get the editor instance that we want to interact with.
danielebarchiesi@0 30 var oEditor = CKEDITOR.instances.editor1;
danielebarchiesi@0 31 var value = document.getElementById( 'htmlArea' ).value;
danielebarchiesi@0 32
danielebarchiesi@0 33 // Check the active editing mode.
danielebarchiesi@0 34 if ( oEditor.mode == 'wysiwyg' )
danielebarchiesi@0 35 {
danielebarchiesi@0 36 // Insert HTML code.
danielebarchiesi@0 37 // http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#insertHtml
danielebarchiesi@0 38 oEditor.insertHtml( value );
danielebarchiesi@0 39 }
danielebarchiesi@0 40 else
danielebarchiesi@0 41 alert( 'You must be in WYSIWYG mode!' );
danielebarchiesi@0 42 }
danielebarchiesi@0 43
danielebarchiesi@0 44 function InsertText()
danielebarchiesi@0 45 {
danielebarchiesi@0 46 // Get the editor instance that we want to interact with.
danielebarchiesi@0 47 var oEditor = CKEDITOR.instances.editor1;
danielebarchiesi@0 48 var value = document.getElementById( 'txtArea' ).value;
danielebarchiesi@0 49
danielebarchiesi@0 50 // Check the active editing mode.
danielebarchiesi@0 51 if ( oEditor.mode == 'wysiwyg' )
danielebarchiesi@0 52 {
danielebarchiesi@0 53 // Insert as plain text.
danielebarchiesi@0 54 // http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#insertText
danielebarchiesi@0 55 oEditor.insertText( value );
danielebarchiesi@0 56 }
danielebarchiesi@0 57 else
danielebarchiesi@0 58 alert( 'You must be in WYSIWYG mode!' );
danielebarchiesi@0 59 }
danielebarchiesi@0 60
danielebarchiesi@0 61 function SetContents()
danielebarchiesi@0 62 {
danielebarchiesi@0 63 // Get the editor instance that we want to interact with.
danielebarchiesi@0 64 var oEditor = CKEDITOR.instances.editor1;
danielebarchiesi@0 65 var value = document.getElementById( 'htmlArea' ).value;
danielebarchiesi@0 66
danielebarchiesi@0 67 // Set editor contents (replace current contents).
danielebarchiesi@0 68 // http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#setData
danielebarchiesi@0 69 oEditor.setData( value );
danielebarchiesi@0 70 }
danielebarchiesi@0 71
danielebarchiesi@0 72 function GetContents()
danielebarchiesi@0 73 {
danielebarchiesi@0 74 // Get the editor instance that you want to interact with.
danielebarchiesi@0 75 var oEditor = CKEDITOR.instances.editor1;
danielebarchiesi@0 76
danielebarchiesi@0 77 // Get editor contents
danielebarchiesi@0 78 // http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#getData
danielebarchiesi@0 79 alert( oEditor.getData() );
danielebarchiesi@0 80 }
danielebarchiesi@0 81
danielebarchiesi@0 82 function ExecuteCommand( commandName )
danielebarchiesi@0 83 {
danielebarchiesi@0 84 // Get the editor instance that we want to interact with.
danielebarchiesi@0 85 var oEditor = CKEDITOR.instances.editor1;
danielebarchiesi@0 86
danielebarchiesi@0 87 // Check the active editing mode.
danielebarchiesi@0 88 if ( oEditor.mode == 'wysiwyg' )
danielebarchiesi@0 89 {
danielebarchiesi@0 90 // Execute the command.
danielebarchiesi@0 91 // http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#execCommand
danielebarchiesi@0 92 oEditor.execCommand( commandName );
danielebarchiesi@0 93 }
danielebarchiesi@0 94 else
danielebarchiesi@0 95 alert( 'You must be in WYSIWYG mode!' );
danielebarchiesi@0 96 }
danielebarchiesi@0 97
danielebarchiesi@0 98 function CheckDirty()
danielebarchiesi@0 99 {
danielebarchiesi@0 100 // Get the editor instance that we want to interact with.
danielebarchiesi@0 101 var oEditor = CKEDITOR.instances.editor1;
danielebarchiesi@0 102 // Checks whether the current editor contents present changes when compared
danielebarchiesi@0 103 // to the contents loaded into the editor at startup
danielebarchiesi@0 104 // http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#checkDirty
danielebarchiesi@0 105 alert( oEditor.checkDirty() );
danielebarchiesi@0 106 }
danielebarchiesi@0 107
danielebarchiesi@0 108 function ResetDirty()
danielebarchiesi@0 109 {
danielebarchiesi@0 110 // Get the editor instance that we want to interact with.
danielebarchiesi@0 111 var oEditor = CKEDITOR.instances.editor1;
danielebarchiesi@0 112 // Resets the "dirty state" of the editor (see CheckDirty())
danielebarchiesi@0 113 // http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#resetDirty
danielebarchiesi@0 114 oEditor.resetDirty();
danielebarchiesi@0 115 alert( 'The "IsDirty" status has been reset' );
danielebarchiesi@0 116 }
danielebarchiesi@0 117
danielebarchiesi@0 118 //]]>
danielebarchiesi@0 119 </script>
danielebarchiesi@0 120
danielebarchiesi@0 121 </head>
danielebarchiesi@0 122 <body>
danielebarchiesi@0 123 <h1 class="samples">
danielebarchiesi@0 124 CKEditor Sample &mdash; Using CKEditor JavaScript API
danielebarchiesi@0 125 </h1>
danielebarchiesi@0 126 <div class="description">
danielebarchiesi@0 127 <p>
danielebarchiesi@0 128 This sample shows how to use the
danielebarchiesi@0 129 <a class="samples" href="http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html">CKEditor JavaScript API</a>
danielebarchiesi@0 130 to interact with the editor at runtime.
danielebarchiesi@0 131 </p>
danielebarchiesi@0 132 <p>
danielebarchiesi@0 133 For details on how to create this setup check the source code of this sample page.
danielebarchiesi@0 134 </p>
danielebarchiesi@0 135 </div>
danielebarchiesi@0 136
danielebarchiesi@0 137 <!-- This <div> holds alert messages to be display in the sample page. -->
danielebarchiesi@0 138 <div id="alerts">
danielebarchiesi@0 139 <noscript>
danielebarchiesi@0 140 <p>
danielebarchiesi@0 141 <strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript
danielebarchiesi@0 142 support, like yours, you should still see the contents (HTML data) and you should
danielebarchiesi@0 143 be able to edit it normally, without a rich editor interface.
danielebarchiesi@0 144 </p>
danielebarchiesi@0 145 </noscript>
danielebarchiesi@0 146 </div>
danielebarchiesi@0 147 <form action="sample_posteddata.php" method="post">
danielebarchiesi@0 148 <textarea cols="100" id="editor1" name="editor1" rows="10">&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://ckeditor.com/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea>
danielebarchiesi@0 149
danielebarchiesi@0 150 <script type="text/javascript">
danielebarchiesi@0 151 //<![CDATA[
danielebarchiesi@0 152 // Replace the <textarea id="editor1"> with an CKEditor instance.
danielebarchiesi@0 153 var editor = CKEDITOR.replace( 'editor1' );
danielebarchiesi@0 154 //]]>
danielebarchiesi@0 155 </script>
danielebarchiesi@0 156
danielebarchiesi@0 157 <div id="eMessage">
danielebarchiesi@0 158 </div>
danielebarchiesi@0 159 <div id="eButtons" style="display: none">
danielebarchiesi@0 160 <input onclick="InsertHTML();" type="button" value="Insert HTML" />
danielebarchiesi@0 161 <input onclick="SetContents();" type="button" value="Set Editor Contents" />
danielebarchiesi@0 162 <input onclick="GetContents();" type="button" value="Get Editor Contents (XHTML)" />
danielebarchiesi@0 163 <br />
danielebarchiesi@0 164 <textarea cols="100" 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 code.&lt;/p&gt;</textarea>
danielebarchiesi@0 165 <br />
danielebarchiesi@0 166 <br />
danielebarchiesi@0 167 <input onclick="InsertText();" type="button" value="Insert Text" />
danielebarchiesi@0 168 <br />
danielebarchiesi@0 169 <textarea cols="100" id="txtArea" rows="3"> First line with some leading whitespaces.
danielebarchiesi@0 170
danielebarchiesi@0 171 Second line of text preceded by two line breaks.</textarea>
danielebarchiesi@0 172 <br />
danielebarchiesi@0 173 <input onclick="ExecuteCommand('bold');" type="button" value="Execute &quot;bold&quot; Command" />
danielebarchiesi@0 174 <input onclick="ExecuteCommand('link');" type="button" value="Execute &quot;link&quot; Command" />
danielebarchiesi@0 175 <br />
danielebarchiesi@0 176 <br />
danielebarchiesi@0 177 <input onclick="CheckDirty();" type="button" value="checkDirty()" />
danielebarchiesi@0 178 <input onclick="ResetDirty();" type="button" value="resetDirty()" />
danielebarchiesi@0 179 </div>
danielebarchiesi@0 180 </form>
danielebarchiesi@0 181 <div id="footer">
danielebarchiesi@0 182 <hr />
danielebarchiesi@0 183 <p>
danielebarchiesi@0 184 CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
danielebarchiesi@0 185 </p>
danielebarchiesi@0 186 <p id="copy">
danielebarchiesi@0 187 Copyright &copy; 2003-2013, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
danielebarchiesi@0 188 Knabben. All rights reserved.
danielebarchiesi@0 189 </p>
danielebarchiesi@0 190 </div>
danielebarchiesi@0 191 </body>
danielebarchiesi@0 192 </html>