X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Feditingblock%2Fplugin.js;h=7d7742f509c15d09af70da047241d1621ba5cc96;hb=f0610347140239143439a511ee2bd48cb784f470;hp=d0bbde85b7398778c3f381a3e04edc2002967d90;hpb=f8fc585c18d287eb325c575596d183122486b641;p=ckeditor.git diff --git a/_source/plugins/editingblock/plugin.js b/_source/plugins/editingblock/plugin.js index d0bbde8..7d7742f 100644 --- a/_source/plugins/editingblock/plugin.js +++ b/_source/plugins/editingblock/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -10,11 +10,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license (function() { - var getMode = function( editor, mode ) - { - return editor._.modes && editor._.modes[ mode || editor.mode ]; - }; - // This is a semaphore used to avoid recursive calls between // the following data handling functions. var isHandlingData; @@ -49,7 +44,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license function setData() { isHandlingData = true; - getMode( editor ).loadData( editor.getData() ); + editor.getMode().loadData( editor.getData() ); isHandlingData = false; } @@ -59,8 +54,11 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { editor.on( 'mode', function() { - setData(); - editor.removeListener( 'mode', arguments.callee ); + if ( editor.mode ) + { + setData(); + editor.removeListener( 'mode', arguments.callee ); + } }); } } @@ -71,7 +69,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( !isHandlingData && editor.mode ) { isHandlingData = true; - editor.setData( getMode( editor ).getData() ); + editor.setData( editor.getMode().getData(), null, 1 ); isHandlingData = false; } }); @@ -79,13 +77,13 @@ For licensing, see LICENSE.html or http://ckeditor.com/license editor.on( 'getSnapshot', function( event ) { if ( editor.mode ) - event.data = getMode( editor ).getSnapshotData(); + event.data = editor.getMode().getSnapshotData(); }); editor.on( 'loadSnapshot', function( event ) { if ( editor.mode ) - getMode( editor ).loadSnapshotData( event.data ); + editor.getMode().loadSnapshotData( event.data ); }); // For the first "mode" call, we'll also fire the "instanceReady" @@ -110,8 +108,15 @@ For licensing, see LICENSE.html or http://ckeditor.com/license setTimeout( function(){ editor.fireOnce( 'instanceReady' ); CKEDITOR.fire( 'instanceReady', null, editor ); - } ); + }, 0 ); }); + + editor.on( 'destroy', function () + { + // -> currentMode.unload( holderElement ); + if ( this.mode ) + this._.modes[ this.mode ].unload( this.getThemeSpace( 'contents' ) ); + }); } }); @@ -146,6 +151,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license */ CKEDITOR.editor.prototype.setMode = function( mode ) { + this.fire( 'beforeSetMode', { newMode : mode } ); + var data, holderElement = this.getThemeSpace( 'contents' ), isDirty = this.checkDirty(); @@ -158,7 +165,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license this.fire( 'beforeModeUnload' ); - var currentMode = getMode( this ); + var currentMode = this.getMode(); data = currentMode.getData(); currentMode.unload( holderElement ); this.mode = ''; @@ -167,7 +174,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license holderElement.setHtml( '' ); // Load required mode. - var modeEditor = getMode( this, mode ); + var modeEditor = this.getMode( mode ); if ( !modeEditor ) throw '[CKEDITOR.editor.setMode] Unknown mode "' + mode + '".'; @@ -184,11 +191,23 @@ For licensing, see LICENSE.html or http://ckeditor.com/license }; /** + * Gets the current or any of the objects that represent the editing + * area modes. The two most common editing modes are "wysiwyg" and "source". + * @param {String} [mode] The mode to be retrieved. If not specified, the + * current one is returned. + */ + CKEDITOR.editor.prototype.getMode = function( mode ) + { + return this._.modes && this._.modes[ mode || this.mode ]; + }; + + /** * Moves the selection focus to the editing are space in the editor. */ CKEDITOR.editor.prototype.focus = function() { - var mode = getMode( this ); + this.forceNextSelectionCheck(); + var mode = this.getMode(); if ( mode ) mode.focus(); }; @@ -206,12 +225,12 @@ CKEDITOR.config.startupMode = 'wysiwyg'; /** * Sets whether the editor should have the focus when the page loads. + * @name CKEDITOR.config.startupFocus * @type Boolean * @default false * @example * config.startupFocus = true; */ -CKEDITOR.config.startupFocus = false; /** * Whether to render or not the editing block area in the editor interface. @@ -228,3 +247,29 @@ CKEDITOR.config.editingBlock = true; * @event * @param {CKEDITOR.editor} editor The editor instance that has been created. */ + +/** + * Fired when the CKEDITOR instance is created, fully initialized and ready for interaction. + * @name CKEDITOR.editor#instanceReady + * @event + */ + +/** + * Fired before changing the editing mode. See also CKEDITOR.editor#beforeSetMode and CKEDITOR.editor#mode + * @name CKEDITOR.editor#beforeModeUnload + * @event + */ + + /** + * Fired before the editor mode is set. See also CKEDITOR.editor#mode and CKEDITOR.editor#beforeModeUnload + * @name CKEDITOR.editor#beforeSetMode + * @event + * @since 3.5.3 + * @param {String} newMode The name of the mode which is about to be set. + */ + +/** + * Fired after setting the editing mode. See also CKEDITOR.editor#beforeSetMode and CKEDITOR.editor#beforeModeUnload + * @name CKEDITOR.editor#mode + * @event + */