X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_source%2Fplugins%2Fwysiwygarea%2Fplugin.js;h=7657a198dc00ece8a6bde2fa62d8cb7f1ce21b06;hp=d6ab1d8f209e6a4a4d49276014a3011738d847e2;hb=2f22c0c38f17e75be5541089076885442aaa2377;hpb=e73319a12b56100b29ef456fd74114fe5519e01c diff --git a/_source/plugins/wysiwygarea/plugin.js b/_source/plugins/wysiwygarea/plugin.js index d6ab1d8..7657a19 100644 --- a/_source/plugins/wysiwygarea/plugin.js +++ b/_source/plugins/wysiwygarea/plugin.js @@ -1,5 +1,5 @@ /* -Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. +Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ @@ -30,10 +30,20 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { this.focus(); + // Since the insertion might happen from within dialog or menu + // where the editor selection might be locked at the moment, + // update the locked selection. + var selection = this.getSelection(), + selIsLocked = selection.isLocked; + + selIsLocked && selection.unlock(); + this.fire( 'saveSnapshot' ); insertFunc.call( this, evt.data ); + selIsLocked && this.getSelection().lock(); + // Save snaps after the whole execution completed. // This's a workaround for make DOM modification's happened after // 'insertElement' to be included either, e.g. Form-based dialogs' 'commitContents' @@ -83,11 +93,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license if ( CKEDITOR.env.ie ) { - var selIsLocked = selection.isLocked; - - if ( selIsLocked ) - selection.unlock(); - var $sel = selection.getNative(); // Delete control selections to avoid IE bugs on pasteHTML. @@ -113,9 +118,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license } $sel.createRange().pasteHTML( data ); - - if ( selIsLocked ) - this.getSelection().lock(); } else this.document.$.execCommand( 'inserthtml', false, data ); @@ -476,6 +478,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license var frameLabel = editor.lang.editorTitle.replace( '%1', editor.name ); + var win = CKEDITOR.document.getWindow(); var contentDomReadyHandler; editor.on( 'editingBlockReady', function() { @@ -484,7 +487,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license isLoadingData, isPendingFocus, frameLoaded, - fireMode; + fireMode, + onResize; // Support for custom document.domain in IE. @@ -546,6 +550,19 @@ For licensing, see LICENSE.html or http://ckeditor.com/license CKEDITOR.event.useCapture = false; mainElement.append( iframe ); + + // Webkit: iframe size doesn't auto fit well. (#7360) + if ( CKEDITOR.env.webkit ) + { + onResize = function() + { + iframe.hide(); + iframe.setSize( 'width', mainElement.getSize( 'width' ) ); + iframe.show(); + }; + + win.on( 'resize', onResize ); + } }; // The script that launches the bootstrap logic on 'domReady', so the document @@ -689,28 +706,6 @@ 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 ( editable && - CKEDITOR.env.ie && domDocument.$.compatMode == 'CSS1Compat' - || CKEDITOR.env.gecko - || CKEDITOR.env.opera ) - { - var htmlElement = domDocument.getDocumentElement(); - htmlElement.on( 'mousedown', function( evt ) - { - // Setting focus directly on editor doesn't work, we - // have to use here a temporary element to 'redirect' - // the focus. - if ( evt.data.getTarget().equals( htmlElement ) ) - { - if ( CKEDITOR.env.gecko && CKEDITOR.env.version >= 10900 ) - blinkCursor(); - focusGrabber.focus(); - } - } ); - } - var focusTarget = CKEDITOR.env.ie ? iframe : domWindow; focusTarget.on( 'blur', function() { @@ -778,6 +773,28 @@ For licensing, see LICENSE.html or http://ckeditor.com/license return; } } + + // PageUp OR PageDown + if ( keyCode == 33 || keyCode == 34 ) + { + if ( CKEDITOR.env.gecko ) + { + var body = domDocument.getBody(); + + // Page up/down cause editor selection to leak + // outside of editable thus we try to intercept + // the behavior, while it affects only happen + // when editor contents are not overflowed. (#7955) + if ( domWindow.$.innerHeight > body.$.offsetHeight ) + { + range = new CKEDITOR.dom.range( domDocument ); + range[ keyCode == 33 ? 'moveToElementEditStart' : 'moveToElementEditEnd']( body ); + range.select(); + evt.data.preventDefault(); + } + } + + } } ); // PageUp/PageDown scrolling is broken in document @@ -803,9 +820,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license domDocument.on( 'selectionchange', function() { var body = domDocument.getBody(), - range = editor.getSelection().getRanges()[ 0 ]; + sel = editor.getSelection(), + range = sel && sel.getRanges()[ 0 ]; - if ( body.getHtml().match( /^

 <\/p>$/i ) + if ( range && body.getHtml().match( /^

 <\/p>$/i ) && range.startContainer.equals( body ) ) { // Avoid the ambiguity from a real user cursor position. @@ -1078,6 +1096,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license { this.onDispose(); + if ( onResize ) + win.removeListener( 'resize', onResize ); + editor.window = editor.document = iframe = mainElement = isPendingFocus = null; editor.fire( 'contentDomUnload' ); @@ -1158,6 +1179,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license editor.addCss( 'html { height: 100% !important; }' ); editor.addCss( 'img:-moz-broken { -moz-force-broken-image-icon : 1; width : 24px; height : 24px; }' ); } + // Remove the margin to avoid mouse confusion. (#8835) + else if ( CKEDITOR.env.ie && CKEDITOR.env.version < 8 && editor.config.contentsLangDirection == 'ltr' ) + editor.addCss( 'body{margin-right:0;}' ); /* #3658: [IE6] Editor document has horizontal scrollbar on long lines To prevent this misbehavior, we show the scrollbar always */ @@ -1198,31 +1222,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license }); } - // Create an invisible element to grab focus. - if ( CKEDITOR.env.gecko || CKEDITOR.env.ie || CKEDITOR.env.opera ) - { - var focusGrabber; - editor.on( 'uiReady', function() - { - focusGrabber = editor.container.append( CKEDITOR.dom.element.createFromHtml( - // Use 'span' instead of anything else to fly under the screen-reader radar. (#5049) - '' ) ); - - focusGrabber.on( 'focus', function() - { - editor.focus(); - } ); - - editor.focusGrabber = focusGrabber; - } ); - editor.on( 'destroy', function() - { - CKEDITOR.tools.removeFunction( contentDomReadyHandler ); - focusGrabber.clearCustomData(); - delete editor.focusGrabber; - } ); - } - // Disable form elements editing mode provided by some browers. (#5746) editor.on( 'insertElement', function ( evt ) {