X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Feditingblock%2Fplugin.js;h=8feabcd2a45c23ca5d94986fb88abb2d75637900;hb=4e70ea24db840898be8cc21c950363a52a2a6aba;hp=dfbe069d0f53dad966818e6fba645f34700b86b5;hpb=48b1db88210b4160dce439c6e3e32e14af8c106b;p=ckeditor.git diff --git a/_source/plugins/editingblock/plugin.js b/_source/plugins/editingblock/plugin.js index dfbe069..8feabcd 100644 --- a/_source/plugins/editingblock/plugin.js +++ b/_source/plugins/editingblock/plugin.js @@ -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" @@ -153,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(); @@ -165,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 = ''; @@ -174,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 + '".'; @@ -191,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(); }; @@ -213,6 +225,7 @@ 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 @@ -242,7 +255,15 @@ CKEDITOR.config.editingBlock = true; */ /** - * Fired before changing the editing mode + * Fired before changing the editing mode. * @name CKEDITOR.editor#beforeModeUnload * @event */ + + /** + * Fired before the editor mode is set. + * @name CKEDITOR.editor#beforeSetMode + * @event + * @since 3.5.3 + * @param {String} newMode The name of the mode which is about to be set. + */