/*\r
-Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.\r
For licensing, see LICENSE.html or http://ckeditor.com/license\r
*/\r
\r
{\r
this.focus();\r
\r
+ // Since the insertion might happen from within dialog or menu\r
+ // where the editor selection might be locked at the moment,\r
+ // update the locked selection.\r
+ var selection = this.getSelection(),\r
+ selIsLocked = selection.isLocked;\r
+\r
+ selIsLocked && selection.unlock();\r
+\r
this.fire( 'saveSnapshot' );\r
\r
insertFunc.call( this, evt.data );\r
\r
+ selIsLocked && this.getSelection().lock();\r
+\r
// Save snaps after the whole execution completed.\r
// This's a workaround for make DOM modification's happened after\r
// 'insertElement' to be included either, e.g. Form-based dialogs' 'commitContents'\r
\r
if ( CKEDITOR.env.ie )\r
{\r
- var selIsLocked = selection.isLocked;\r
-\r
- if ( selIsLocked )\r
- selection.unlock();\r
-\r
var $sel = selection.getNative();\r
\r
// Delete control selections to avoid IE bugs on pasteHTML.\r
}\r
\r
$sel.createRange().pasteHTML( data );\r
-\r
- if ( selIsLocked )\r
- this.getSelection().lock();\r
}\r
else\r
this.document.$.execCommand( 'inserthtml', false, data );\r
\r
var frameLabel = editor.lang.editorTitle.replace( '%1', editor.name );\r
\r
+ var win = CKEDITOR.document.getWindow();\r
var contentDomReadyHandler;\r
editor.on( 'editingBlockReady', function()\r
{\r
isLoadingData,\r
isPendingFocus,\r
frameLoaded,\r
- fireMode;\r
+ fireMode,\r
+ onResize;\r
\r
\r
// Support for custom document.domain in IE.\r
CKEDITOR.event.useCapture = false;\r
\r
mainElement.append( iframe );\r
+\r
+ // Webkit: iframe size doesn't auto fit well. (#7360)\r
+ if ( CKEDITOR.env.webkit )\r
+ {\r
+ onResize = function()\r
+ {\r
+ iframe.hide();\r
+ iframe.setSize( 'width', mainElement.getSize( 'width' ) );\r
+ iframe.show();\r
+ };\r
+\r
+ win.on( 'resize', onResize );\r
+ }\r
};\r
\r
// The script that launches the bootstrap logic on 'domReady', so the document\r
} );\r
}\r
\r
- // IE standard compliant in editing frame doesn't focus the editor when\r
- // clicking outside actual content, manually apply the focus. (#1659)\r
- if ( editable &&\r
- CKEDITOR.env.ie && domDocument.$.compatMode == 'CSS1Compat'\r
- || CKEDITOR.env.gecko\r
- || CKEDITOR.env.opera )\r
- {\r
- var htmlElement = domDocument.getDocumentElement();\r
- htmlElement.on( 'mousedown', function( evt )\r
- {\r
- // Setting focus directly on editor doesn't work, we\r
- // have to use here a temporary element to 'redirect'\r
- // the focus.\r
- if ( evt.data.getTarget().equals( htmlElement ) )\r
- {\r
- if ( CKEDITOR.env.gecko && CKEDITOR.env.version >= 10900 )\r
- blinkCursor();\r
- focusGrabber.focus();\r
- }\r
- } );\r
- }\r
-\r
var focusTarget = CKEDITOR.env.ie ? iframe : domWindow;\r
focusTarget.on( 'blur', function()\r
{\r
return;\r
}\r
}\r
+\r
+ // PageUp OR PageDown\r
+ if ( keyCode == 33 || keyCode == 34 )\r
+ {\r
+ if ( CKEDITOR.env.gecko )\r
+ {\r
+ var body = domDocument.getBody();\r
+\r
+ // Page up/down cause editor selection to leak\r
+ // outside of editable thus we try to intercept\r
+ // the behavior, while it affects only happen\r
+ // when editor contents are not overflowed. (#7955)\r
+ if ( domWindow.$.innerHeight > body.$.offsetHeight )\r
+ {\r
+ range = new CKEDITOR.dom.range( domDocument );\r
+ range[ keyCode == 33 ? 'moveToElementEditStart' : 'moveToElementEditEnd']( body );\r
+ range.select();\r
+ evt.data.preventDefault();\r
+ }\r
+ }\r
+\r
+ }\r
} );\r
\r
// PageUp/PageDown scrolling is broken in document\r
domDocument.on( 'selectionchange', function()\r
{\r
var body = domDocument.getBody(),\r
- range = editor.getSelection().getRanges()[ 0 ];\r
+ sel = editor.getSelection(),\r
+ range = sel && sel.getRanges()[ 0 ];\r
\r
- if ( body.getHtml().match( /^<p> <\/p>$/i )\r
+ if ( range && body.getHtml().match( /^<p> <\/p>$/i )\r
&& range.startContainer.equals( body ) )\r
{\r
// Avoid the ambiguity from a real user cursor position.\r
{\r
this.onDispose();\r
\r
+ if ( onResize )\r
+ win.removeListener( 'resize', onResize );\r
+\r
editor.window = editor.document = iframe = mainElement = isPendingFocus = null;\r
\r
editor.fire( 'contentDomUnload' );\r
editor.addCss( 'html { height: 100% !important; }' );\r
editor.addCss( 'img:-moz-broken { -moz-force-broken-image-icon : 1; width : 24px; height : 24px; }' );\r
}\r
+ // Remove the margin to avoid mouse confusion. (#8835)\r
+ else if ( CKEDITOR.env.ie && CKEDITOR.env.version < 8 && editor.config.contentsLangDirection == 'ltr' )\r
+ editor.addCss( 'body{margin-right:0;}' );\r
\r
/* #3658: [IE6] Editor document has horizontal scrollbar on long lines\r
To prevent this misbehavior, we show the scrollbar always */\r
});\r
}\r
\r
- // Create an invisible element to grab focus.\r
- if ( CKEDITOR.env.gecko || CKEDITOR.env.ie || CKEDITOR.env.opera )\r
- {\r
- var focusGrabber;\r
- editor.on( 'uiReady', function()\r
- {\r
- focusGrabber = editor.container.append( CKEDITOR.dom.element.createFromHtml(\r
- // Use 'span' instead of anything else to fly under the screen-reader radar. (#5049)\r
- '<span tabindex="-1" style="position:absolute;" role="presentation"></span>' ) );\r
-\r
- focusGrabber.on( 'focus', function()\r
- {\r
- editor.focus();\r
- } );\r
-\r
- editor.focusGrabber = focusGrabber;\r
- } );\r
- editor.on( 'destroy', function()\r
- {\r
- CKEDITOR.tools.removeFunction( contentDomReadyHandler );\r
- focusGrabber.clearCustomData();\r
- delete editor.focusGrabber;\r
- } );\r
- }\r
-\r
// Disable form elements editing mode provided by some browers. (#5746)\r
editor.on( 'insertElement', function ( evt )\r
{\r