// Initialize all plugins that have the "beforeInit" and "init" methods defined. var methods = [ 'beforeInit', 'init', 'afterInit' ]; for ( var m = 0; m < methods.length; m++ ) { for ( var i = 0; i < pluginsArray.length; i++ ) { var plugin = pluginsArray[ i ]; // Uses the first loop to update the language entries also. if ( m === 0 && languageCodes[ i ] && plugin.lang && plugin.langEntries ) editor.lang[ plugin.name ] = plugin.langEntries[ languageCodes[ i ] ]; // Call the plugin method (beforeInit and init). if ( plugin[ methods[ m ] ] ) plugin[ methods[ m ] ]( editor ); } }
CKEDITOR.on( 'instanceLoaded', function( evt ) { var editor = evt.editor; // and flag that the element was locked by our code so it'll be editable by the editor functions (#6046). editor.on( 'insertElement', function( evt ) { var element = evt.data; if ( element.type == CKEDITOR.NODE_ELEMENT && ( element.is( 'input' ) || element.is( 'textarea' ) ) ) { // // The element is still not inserted yet, force attribute-based check. if ( element.getAttribute( 'contentEditable' ) != 'false' ) element.data( 'cke-editable', element.hasAttribute( 'contenteditable' ) ? 'true' : '1' ); element.setAttribute( 'contentEditable', false ); } } ); editor.on( 'selectionChange', function( evt ) { if ( editor.readOnly ) return; // Auto fixing on some document structure weakness to enhance usabilities. (#3190 and #3189) var sel = editor.getSelection(); // Do it only when selection is not locked. (#8222) if ( sel && !sel.isLocked ) { var isDirty = editor.checkDirty(); // Lock undoM before touching DOM to prevent // recording these changes as separate snapshot. editor.fire( 'lockSnapshot' ); fixDom( evt ); editor.fire( 'unlockSnapshot' ); !isDirty && editor.resetDirty(); } } ); } );
for ( var pluginName in plugins ) { var plugin = plugins[ pluginName ], requires = plugin && plugin.requires; if ( !initialized[ pluginName ] ) { // Register all icons eventually defined by this plugin. if ( plugin.icons ) { var icons = plugin.icons.split( ',' ); for ( var ic = icons.length; ic--; ) { CKEDITOR.skin.addIcon( icons[ ic ], plugin.path + 'icons/' + ( CKEDITOR.env.hidpi && plugin.hidpi ? 'hidpi/' : '' ) + icons[ ic ] + '.png' ); } } initialized[ pluginName ] = 1; } if ( requires ) { // Trasnform it into an array, if it's not one. if ( requires.split ) requires = requires.split( ',' ); for ( var i = 0; i < requires.length; i++ ) { if ( !allPlugins[ requires[ i ] ] ) requiredPlugins.push( requires[ i ] ); } } }