X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fcore%2Feditor.js;h=c0653010ff1dbbb0e1e9e72ee5b75d9371481e24;hb=refs%2Ftags%2Fv3.1;hp=d9017c0380becf0a0a3800acfc2ae228f3664563;hpb=ea7e3453c7b0f023b050aca6d9f83ab372860d91;p=ckeditor.git
diff --git a/_source/core/editor.js b/_source/core/editor.js
index d9017c0..c065301 100644
--- a/_source/core/editor.js
+++ b/_source/core/editor.js
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
@@ -33,6 +33,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
if ( !customConfig )
return false;
+ customConfig = CKEDITOR.getUrl( customConfig );
+
var loadedConfig = loadConfigLoaded[ customConfig ] || ( loadConfigLoaded[ customConfig ] = {} );
// If the custom config has already been downloaded, reuse it.
@@ -44,7 +46,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
// If there is no other customConfig in the chain, fire the
// "configLoaded" event.
- if ( editor.config.customConfig == customConfig || !loadConfig( editor ) )
+ if ( CKEDITOR.getUrl( editor.config.customConfig ) == customConfig || !loadConfig( editor ) )
editor.fireOnce( 'customConfigLoaded' );
}
else
@@ -113,6 +115,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
var skin = editor.config.skin.split( ',' ),
skinName = skin[ 0 ],
skinPath = CKEDITOR.getUrl( skin[ 1 ] || (
+ '_source/' + // @Packager.RemoveLine
'skins/' + skinName + '/' ) );
editor.skinName = skinName;
@@ -123,7 +126,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
editor.fireOnce( 'configLoaded' );
// Load language file.
- loadLang( editor );
+ loadSkin( editor );
};
var loadLang = function( editor )
@@ -245,7 +248,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
// Load the editor skin.
editor.fire( 'pluginsLoaded' );
- loadSkin( editor );
+ loadTheme( editor );
});
});
};
@@ -254,7 +257,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
{
CKEDITOR.skins.load( editor, 'editor', function()
{
- loadTheme( editor );
+ loadLang( editor );
});
};
@@ -435,6 +438,13 @@ CKEDITOR.tools.extend( CKEDITOR.editor.prototype,
return this._.commands[ commandName ] = new CKEDITOR.command( this, commandDefinition );
},
+ /**
+ * Add a trunk of css text to the editor which will be applied to the wysiwyg editing document.
+ * Note: This function should be called before editor is loaded to take effect.
+ * @param css {String} CSS text.
+ * @example
+ * editorInstance.addCss( 'body { background-color: grey; }' );
+ */
addCss : function( css )
{
this._.styles.push( css );
@@ -459,6 +469,7 @@ CKEDITOR.tools.extend( CKEDITOR.editor.prototype,
this.theme.destroy( this );
this.fire( 'destroy' );
CKEDITOR.remove( this );
+ CKEDITOR.fire( 'instanceDestroyed', null, this );
},
/**
@@ -564,13 +575,30 @@ CKEDITOR.tools.extend( CKEDITOR.editor.prototype,
},
/**
- * Sets the editor data. The data must be provided in raw format.
+ * Sets the editor data. The data must be provided in raw format (HTML).
+ * Note: This's an asynchronous method, the {@param callback}
+ * function should be relied on if you want to interact with the editor
+ * after data is fully loaded.
+ *
* @param {String} data HTML code to replace the curent content in the editor.
+ * @param {Function} callback Function to be called after the setData is completed.
* @example
* CKEDITOR.instances.editor1.setData( '<p>This is the editor data.</p>' );
+ * CKEDITOR.instances.editor1.setData( '<p>Some other editor data.</p>', function()
+ * {
+ * CKEDITOR.instances.editor1.checkDirty(); // true
+ * } );
*/
- setData : function( data )
+ setData : function( data , callback )
{
+ if( callback )
+ {
+ this.on( 'dataReady', function( evt )
+ {
+ evt.removeListener();
+ callback.call( evt.editor );
+ } );
+ }
// Fire "setData" so data manipulation may happen.
var eventData = { dataValue : data };
this.fire( 'setData', eventData );
@@ -628,10 +656,15 @@ CKEDITOR.tools.extend( CKEDITOR.editor.prototype,
var element = this.element;
if ( element && this.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE )
{
+ var data = this.getData();
+
+ if( this.config.htmlEncodeOutput )
+ data = CKEDITOR.tools.htmlEncode( data );
+
if ( element.is( 'textarea' ) )
- element.setValue( this.getData() );
+ element.setValue( data );
else
- element.setHtml( this.getData() );
+ element.setHtml( data );
}
}
});
@@ -648,3 +681,12 @@ CKEDITOR.on( 'loaded', function()
pending[ i ]._init();
}
});
+
+/**
+ * Whether escape HTML when editor update original input element.
+ * @name CKEDITOR.config.htmlEncodeOutput
+ * @type {Boolean}
+ * @default false
+ * @example
+ * config.htmlEncodeOutput = true;
+ */