/*\r
-Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
*/\r
editor.tabIndex = editor.config.tabIndex || editor.element.getAttribute( 'tabindex' ) || 0;\r
\r
+ /**\r
+ * Indicates the read-only state of this editor. This is a read-only property.\r
+ * @name CKEDITOR.editor.prototype.readOnly\r
+ * @type Boolean\r
+ * @since 3.6\r
+ * @see CKEDITOR.editor#setReadOnly\r
+ */\r
+ editor.readOnly = !!( editor.config.readOnly || editor.element.getAttribute( 'disabled' ) );\r
+\r
// Fire the "configLoaded" event.\r
editor.fireOnce( 'configLoaded' );\r
\r
plugins = plugins.replace( removeRegex, '' );\r
}\r
\r
+ // Load the Adobe AIR plugin conditionally.\r
+ CKEDITOR.env.air && ( plugins += ',adobeair' );\r
+\r
// Load all plugins defined in the "plugins" setting.\r
CKEDITOR.plugins.load( plugins.split( ',' ), function( plugins )\r
{\r
// is not available, get the first one (default one).\r
lang = ( CKEDITOR.tools.indexOf( pluginLangs, editor.langCode ) >= 0 ? editor.langCode : pluginLangs[ 0 ] );\r
\r
- if ( !plugin.lang[ lang ] )\r
+ if ( !plugin.langEntries || !plugin.langEntries[ lang ] )\r
{\r
// Put the language file URL into the list of files to\r
// get downloaded.\r
}\r
else\r
{\r
- CKEDITOR.tools.extend( editor.lang, plugin.lang[ lang ] );\r
+ CKEDITOR.tools.extend( editor.lang, plugin.langEntries[ lang ] );\r
lang = null;\r
}\r
}\r
\r
// Uses the first loop to update the language entries also.\r
if ( m === 0 && languageCodes[ i ] && plugin.lang )\r
- CKEDITOR.tools.extend( editor.lang, plugin.lang[ languageCodes[ i ] ] );\r
+ CKEDITOR.tools.extend( editor.lang, plugin.langEntries[ languageCodes[ i ] ] );\r
\r
// Call the plugin method (beforeInit and init).\r
if ( plugin[ methods[ m ] ] )\r
\r
// Setup the submit function because it doesn't fire the\r
// "submit" event.\r
- if ( !form.$.submit.nodeName )\r
+ if ( !form.$.submit.nodeName && !form.$.submit.length )\r
{\r
form.$.submit = CKEDITOR.tools.override( form.$.submit, function( originalSubmit )\r
{\r
}\r
};\r
\r
- function updateCommandsMode()\r
+ function updateCommands()\r
{\r
var command,\r
commands = this._.commands,\r
mode = this.mode;\r
\r
+ if ( !mode )\r
+ return;\r
+\r
for ( var name in commands )\r
{\r
command = commands[ name ];\r
- command[ command.startDisabled ? 'disable' : command.modes[ mode ] ? 'enable' : 'disable' ]();\r
+ command[ command.startDisabled ? 'disable' :\r
+ this.readOnly && !command.readOnly ? 'disable' : command.modes[ mode ] ? 'enable' : 'disable' ]();\r
}\r
}\r
\r
\r
CKEDITOR.fire( 'instanceCreated', null, this );\r
\r
- this.on( 'mode', updateCommandsMode, null, null, 1 );\r
+ this.on( 'mode', updateCommands, null, null, 1 );\r
+ this.on( 'readOnly', updateCommands, null, null, 1 );\r
\r
initConfig( this, instanceConfig );\r
};\r
if ( !noUpdate )\r
this.updateElement();\r
\r
- if ( this.mode )\r
- {\r
- // -> currentMode.unload( holderElement );\r
- this._.modes[ this.mode ].unload( this.getThemeSpace( 'contents' ) );\r
- }\r
-\r
- this.theme.destroy( this );\r
-\r
- var toolbars,\r
- index = 0,\r
- j,\r
- items,\r
- instance;\r
-\r
- if ( this.toolbox )\r
- {\r
- toolbars = this.toolbox.toolbars;\r
- for ( ; index < toolbars.length ; index++ )\r
- {\r
- items = toolbars[ index ].items;\r
- for ( j = 0 ; j < items.length ; j++ )\r
- {\r
- instance = items[ j ];\r
- if ( instance.clickFn ) CKEDITOR.tools.removeFunction( instance.clickFn );\r
- if ( instance.keyDownFn ) CKEDITOR.tools.removeFunction( instance.keyDownFn );\r
-\r
- if ( instance.index ) CKEDITOR.ui.button._.instances[ instance.index ] = null;\r
- }\r
- }\r
- }\r
-\r
- if ( this.contextMenu )\r
- CKEDITOR.tools.removeFunction( this.contextMenu._.functionId );\r
-\r
- if ( this._.filebrowserFn )\r
- CKEDITOR.tools.removeFunction( this._.filebrowserFn );\r
-\r
this.fire( 'destroy' );\r
+ this.theme && this.theme.destroy( this );\r
+\r
CKEDITOR.remove( this );\r
CKEDITOR.fire( 'instanceDestroyed', null, this );\r
},\r
* @returns {Boolean} "true" if the command has been successfuly\r
* executed, otherwise "false".\r
* @example\r
- * editorInstance.execCommand( 'Bold' );\r
+ * editorInstance.execCommand( 'bold' );\r
*/\r
execCommand : function( commandName, data )\r
{\r
* editor.\r
* @param {Function} callback Function to be called after the setData\r
* is completed.\r
+ *@param {Boolean} internal Whether suppress any event firing when copying data internally inside editor.\r
* @example\r
* CKEDITOR.instances.editor1.<b>setData</b>( '<p>This is the editor data.</p>' );\r
* @example\r
* this.checkDirty(); // true\r
* });\r
*/\r
- setData : function( data , callback )\r
+ setData : function( data , callback, internal )\r
{\r
if( callback )\r
{\r
\r
// Fire "setData" so data manipulation may happen.\r
var eventData = { dataValue : data };\r
- this.fire( 'setData', eventData );\r
+ !internal && this.fire( 'setData', eventData );\r
\r
this._.data = eventData.dataValue;\r
\r
- this.fire( 'afterSetData', eventData );\r
+ !internal && this.fire( 'afterSetData', eventData );\r
+ },\r
+\r
+ /**\r
+ * Puts or restores the editor into read-only state. When in read-only,\r
+ * the user is not able to change the editor contents, but still use\r
+ * some editor features. This function sets the readOnly property of\r
+ * the editor, firing the "readOnly" event.<br><br>\r
+ * <strong>Note:</strong> the current editing area will be reloaded.\r
+ * @param {Boolean} [makeEditable] Indicates that the editor must be\r
+ * restored from read-only mode, making it editable.\r
+ * @since 3.6\r
+ */\r
+ setReadOnly : function( makeEditable )\r
+ {\r
+ if ( this.readOnly != !makeEditable )\r
+ {\r
+ this.readOnly = !makeEditable;\r
+\r
+ // Fire the readOnly event so the editor features can update\r
+ // their state accordingly.\r
+ this.fire( 'readOnly' );\r
+ }\r
},\r
\r
/**\r
},\r
\r
/**\r
+ * Insert text content into the currently selected position in the\r
+ * editor, in WYSIWYG mode, styles of the selected element will be applied to the inserted text,\r
+ * spaces around the text will be leaving untouched.\r
+ * <strong>Note:</strong> two subsequent line-breaks will introduce one paragraph, which element depends on {@link CKEDITOR.config.enterMode};\r
+ * A single line-break will be instead translated into one <br />.\r
+ * @since 3.5\r
+ * @param {String} text Text to be inserted into the editor.\r
+ * @example\r
+ * CKEDITOR.instances.editor1.<b>insertText( ' line1 \n\n line2' )</b>;\r
+ */\r
+ insertText : function( text )\r
+ {\r
+ this.fire( 'insertText', text );\r
+ },\r
+\r
+ /**\r
* Inserts an element into the currently selected position in the\r
* editor.\r
* @param {CKEDITOR.dom.element} element The element to be inserted\r
*/\r
\r
/**\r
+ * If "true", makes the editor start in read-only state. Otherwise, it'll check\r
+ * if the linked <textarea> has the "disabled" attribute.\r
+ * @name CKEDITOR.config.readOnly\r
+ * @see CKEDITOR.editor#setReadOnly\r
+ * @type Boolean\r
+ * @default false\r
+ * @since 3.6\r
+ * @example\r
+ * config.readOnly = true;\r
+ */\r
+\r
+/**\r
* Fired when a CKEDITOR instance is created, but still before initializing it.\r
* To interact with a fully initialized instance, use the\r
* {@link CKEDITOR#instanceReady} event instead.\r
\r
/**\r
* Fired when all plugins are loaded and initialized into the editor instance.\r
- * @name CKEDITOR#pluginsLoaded\r
+ * @name CKEDITOR.editor#pluginsLoaded\r
* @event\r
- * @param {CKEDITOR.editor} editor The editor instance that has been destroyed.\r
+ * @param {CKEDITOR.editor} editor This editor instance.\r
*/\r
\r
/**\r
* if( editor.config.fullPage )\r
* alert( 'This is a full page editor' );\r
*/\r
+\r
+/**\r
+ * Fired when this editor instance is destroyed. The editor at this\r
+ * point isn't usable and this event should be used to perform clean up\r
+ * in any plugin.\r
+ * @name CKEDITOR.editor#destroy\r
+ * @event\r
+ */\r
+\r
+/**\r
+ * Internal event to get the current data.\r
+ * @name CKEDITOR.editor#beforeGetData\r
+ * @event\r
+ */\r
+\r
+/**\r
+ * Internal event to perform the #getSnapshot call.\r
+ * @name CKEDITOR.editor#getSnapshot\r
+ * @event\r
+ */\r
+\r
+/**\r
+ * Internal event to perform the #loadSnapshot call.\r
+ * @name CKEDITOR.editor#loadSnapshot\r
+ * @event\r
+ */\r
+\r
+\r
+/**\r
+ * Event fired before the #getData call returns allowing additional manipulation.\r
+ * @name CKEDITOR.editor#getData\r
+ * @event\r
+ * @param {CKEDITOR.editor} editor This editor instance.\r
+ * @param {String} data.dataValue The data that will be returned.\r
+ */\r
+\r
+/**\r
+ * Event fired before the #setData call is executed allowing additional manipulation.\r
+ * @name CKEDITOR.editor#setData\r
+ * @event\r
+ * @param {CKEDITOR.editor} editor This editor instance.\r
+ * @param {String} data.dataValue The data that will be used.\r
+ */\r
+\r
+/**\r
+ * Event fired at the end of the #setData call is executed. Usually it's better to use the\r
+ * {@link CKEDITOR.editor.prototype.dataReady} event.\r
+ * @name CKEDITOR.editor#afterSetData\r
+ * @event\r
+ * @param {CKEDITOR.editor} editor This editor instance.\r
+ * @param {String} data.dataValue The data that has been set.\r
+ */\r
+\r
+/**\r
+ * Internal event to perform the #insertHtml call\r
+ * @name CKEDITOR.editor#insertHtml\r
+ * @event\r
+ * @param {CKEDITOR.editor} editor This editor instance.\r
+ * @param {String} data The HTML to insert.\r
+ */\r
+\r
+/**\r
+ * Internal event to perform the #insertText call\r
+ * @name CKEDITOR.editor#insertText\r
+ * @event\r
+ * @param {CKEDITOR.editor} editor This editor instance.\r
+ * @param {String} text The text to insert.\r
+ */\r
+\r
+/**\r
+ * Internal event to perform the #insertElement call\r
+ * @name CKEDITOR.editor#insertElement\r
+ * @event\r
+ * @param {CKEDITOR.editor} editor This editor instance.\r
+ * @param {Object} element The element to insert.\r
+ */\r
+\r
+/**\r
+ * Event fired after {@link CKEDITOR.editor#readOnly} property changes.\r
+ * @name CKEDITOR.editor#readOnly\r
+ * @event\r
+ * @since 3.6\r
+ * @param {CKEDITOR.editor} editor This editor instance.\r
+ */\r