X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Fwysiwygarea%2Fplugin.js;h=11fd76eb32f24108b9fcfd03ab6f95e94fb58a04;hp=c2a8b152f9e364f13676ca85bdfd1a14b450b3e6;hb=c6e377a02b54abc07129d72b632763c727476a15;hpb=941b0a9ba4e673e292510d80a5a86806994b8ea6 diff --git a/_source/plugins/wysiwygarea/plugin.js b/_source/plugins/wysiwygarea/plugin.js index c2a8b15..11fd76e 100644 --- a/_source/plugins/wysiwygarea/plugin.js +++ b/_source/plugins/wysiwygarea/plugin.js @@ -89,7 +89,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license var current, dtd; if ( isBlock ) { - while( ( current = range.getCommonAncestor( false, true ) ) + while ( ( current = range.getCommonAncestor( false, true ) ) && ( dtd = CKEDITOR.dtd[ current.getName() ] ) && !( dtd && dtd [ elementName ] ) ) { @@ -143,7 +143,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // DOM modification here should not bother dirty flag.(#4385) function restoreDirty( editor ) { - if( !editor.checkDirty() ) + if ( !editor.checkDirty() ) setTimeout( function(){ editor.resetDirty(); } ); } @@ -195,7 +195,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // If the fixed block is blank and already followed by a exitable // block, we should revert the fix. (#3684) - if( fixedBlock.getOuterHtml().match( emptyParagraphRegexp ) ) + if ( fixedBlock.getOuterHtml().match( emptyParagraphRegexp ) ) { var previousElement = fixedBlock.getPrevious( isNotWhitespace ), nextElement = fixedBlock.getNext( isNotWhitespace ); @@ -214,7 +214,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license range.select(); // Notify non-IE that selection has changed. - if( !CKEDITOR.env.ie ) + if ( !CKEDITOR.env.ie ) editor.selectionChange(); } @@ -225,7 +225,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( lastNode && lastNode.getName && ( lastNode.getName() in nonExitableElementNames ) ) { restoreDirty( editor ); - if( !CKEDITOR.env.ie ) + if ( !CKEDITOR.env.ie ) body.appendBogus(); else body.append( editor.document.createText( '\xa0' ) ); @@ -267,12 +267,13 @@ For licensing, see LICENSE.html or http://ckeditor.com/license iframe = CKEDITOR.dom.element.createFromHtml( '' + + ''; @@ -416,7 +417,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license // IE standard compliant in editing frame doesn't focus the editor when // clicking outside actual content, manually apply the focus. (#1659) - if( CKEDITOR.env.ie + if ( CKEDITOR.env.ie && domDocument.$.compatMode == 'CSS1Compat' ) { var htmlElement = domDocument.getDocumentElement(); @@ -445,10 +446,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( CKEDITOR.env.gecko ) { var first = body; - while( first.firstChild ) + while ( first.firstChild ) first = first.firstChild; - if( !first.nextSibling + if ( !first.nextSibling && ( 'BR' == first.tagName ) && first.hasAttribute( '_moz_editor_bogus_node' ) ) { @@ -475,31 +476,45 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( CKEDITOR.env.ie ) { - // Cancel default action for backspace in IE on control types. (#4047) + // Override keystrokes which should have deletion behavior + // on control types in IE . (#4047) domDocument.on( 'keydown', function( evt ) { - // Backspace. - var control = evt.data.getKeystroke() == 8 - && editor.getSelection().getSelectedElement(); - if ( control ) + var keyCode = evt.data.getKeystroke(); + + // Backspace OR Delete. + if ( keyCode in { 8 : 1, 46 : 1 } ) { - // Make undo snapshot. - editor.fire( 'saveSnapshot' ); - // Remove manually. - control.remove(); - editor.fire( 'saveSnapshot' ); - evt.cancel(); + var sel = editor.getSelection(), + control = sel.getSelectedElement(); + + if ( control ) + { + // Make undo snapshot. + editor.fire( 'saveSnapshot' ); + + // Delete any element that 'hasLayout' (e.g. hr,table) in IE8 will + // break up the selection, safely manage it here. (#4795) + var bookmark = sel.getRanges()[ 0 ].createBookmark(); + // Remove the control manually. + control.remove(); + sel.selectBookmarks( [ bookmark ] ); + + editor.fire( 'saveSnapshot' ); + + evt.data.preventDefault(); + } } } ); // PageUp/PageDown scrolling is broken in document // with standard doctype, manually fix it. (#4736) - if( domDocument.$.compatMode == 'CSS1Compat' ) + if ( domDocument.$.compatMode == 'CSS1Compat' ) { var pageUpDownKeys = { 33 : 1, 34 : 1 }; domDocument.on( 'keydown', function( evt ) { - if( evt.data.getKeystroke() in pageUpDownKeys ) + if ( evt.data.getKeystroke() in pageUpDownKeys ) { setTimeout( function () { @@ -745,7 +760,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license }); // Create an invisible element to grab focus. - if( CKEDITOR.env.ie ) + if ( CKEDITOR.env.ie ) { var ieFocusGrabber; editor.on( 'uiReady', function() @@ -763,30 +778,28 @@ For licensing, see LICENSE.html or http://ckeditor.com/license }); // Fixing Firefox 'Back-Forward Cache' break design mode. (#4514) - if( CKEDITOR.env.gecko ) + if ( CKEDITOR.env.gecko ) { - var topWin = window.top; - ( function () { - var topBody = topWin.document.body; + var body = document.body; - if( !topBody ) - topWin.addEventListener( 'load', arguments.callee, false ); + if ( !body ) + window.addEventListener( 'load', arguments.callee, false ); else { - topBody.setAttribute( 'onpageshow', topBody.getAttribute( 'onpageshow' ) + body.setAttribute( 'onpageshow', body.getAttribute( 'onpageshow' ) + ';event.persisted && CKEDITOR.tools.callFunction(' + CKEDITOR.tools.addFunction( function() { var allInstances = CKEDITOR.instances, editor, doc; - for( var i in allInstances ) + for ( var i in allInstances ) { editor = allInstances[ i ]; doc = editor.document; - if( doc ) + if ( doc ) { doc.$.designMode = 'off'; doc.$.designMode = 'on'; @@ -845,3 +858,9 @@ CKEDITOR.config.disableNativeSpellChecker = true; * config.ignoreEmptyParagraph = false; */ CKEDITOR.config.ignoreEmptyParagraph = true; + +/** + * Fired when data is loaded and ready for retrieval in an editor instance. + * @name CKEDITOR.editor#dataReady + * @event + */