X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=_source%2Fplugins%2Feditingblock%2Fplugin.js;h=8feabcd2a45c23ca5d94986fb88abb2d75637900;hb=refs%2Ftags%2Fv3.6;hp=05d78b6a35f0ca50d213e6f79d9f59db7b6cb605;hpb=1056598c95187351dc58f4991d331e2258d038b5;p=ckeditor.git diff --git a/_source/plugins/editingblock/plugin.js b/_source/plugins/editingblock/plugin.js index 05d78b6..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(), null, 1 ); + 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" @@ -167,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 = ''; @@ -176,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 + '".'; @@ -193,12 +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() { this.forceNextSelectionCheck(); - var mode = getMode( this ); + var mode = this.getMode(); if ( mode ) mode.focus(); };