JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.2.2
[ckeditor.git] / _source / plugins / clipboard / dialogs / paste.js
index 70527ad..496b8a6 100644 (file)
@@ -11,18 +11,23 @@ CKEDITOR.dialog.add( 'paste', function( editor )
        function onPasteFrameLoad( win )\r
        {\r
                var doc =  new CKEDITOR.dom.document( win.document ),\r
-                       $ = doc.$;\r
+                       docElement = doc.$;\r
 \r
                doc.getById( "cke_actscrpt" ).remove();\r
 \r
                CKEDITOR.env.ie ?\r
-                       $.body.contentEditable = "true" :\r
-                       $.designMode = "on";\r
+                       docElement.body.contentEditable = "true" :\r
+                       docElement.designMode = "on";\r
 \r
-               CKEDITOR.env.ie && doc.getWindow().on( 'blur', function()\r
+               // IE before version 8 will leave cursor blinking inside the document after\r
+               // editor blurred unless we clean up the selection. (#4716)\r
+               if ( CKEDITOR.env.ie && CKEDITOR.env.version < 8 )\r
                {\r
-                        $.body.contentEditable = "false";\r
-               } );\r
+                       doc.getWindow().on( 'blur', function()\r
+                       {\r
+                               docElement.selection.empty();\r
+                       } );\r
+               }\r
 \r
                doc.on( "keydown", function( e )\r
                {\r
@@ -60,10 +65,14 @@ CKEDITOR.dialog.add( 'paste', function( editor )
                        // inserted iframe editable. (#3366)\r
                        this.parts.dialog.$.offsetHeight;\r
 \r
-                       var htmlToLoad = '<!doctype html><html><head><style>body { margin: 3px; height: 95%; } </style></head><body>' +\r
-                                                        '<script id="cke_actscrpt" type="text/javascript">' +\r
-                                                        'window.parent.CKEDITOR.tools.callFunction( ' + CKEDITOR.tools.addFunction( onPasteFrameLoad, this ) + ', this );' +\r
-                                                        '</script></body></html>';\r
+                       var htmlToLoad =\r
+                               '<html dir="' + editor.config.contentsLangDirection + '"' +\r
+                               ' lang="' + ( editor.config.contentsLanguage || editor.langCode ) + '">' +\r
+                                       '<head><style>body { margin: 3px; height: 95%; } </style></head><body>' +\r
+                                       '<script id="cke_actscrpt" type="text/javascript">' +\r
+                                       'window.parent.CKEDITOR.tools.callFunction( ' + CKEDITOR.tools.addFunction( onPasteFrameLoad, this ) + ', this );' +\r
+                                       '</script></body>' +\r
+                               '</html>';\r
 \r
                        var iframe = CKEDITOR.dom.element.createFromHtml(\r
                                                '<iframe' +\r
@@ -108,6 +117,25 @@ CKEDITOR.dialog.add( 'paste', function( editor )
                        container.setHtml( '' );\r
                        container.append( iframe );\r
 \r
+                       // IE need a redirect on focus to make\r
+                       // the cursor blinking inside iframe. (#5461)\r
+                       if ( CKEDITOR.env.ie )\r
+                       {\r
+                               var focusGrabber = CKEDITOR.dom.element.createFromHtml( '<span tabindex="-1" style="position:absolute;" role="presentation"></span>' );\r
+                               focusGrabber.on( 'focus', function()\r
+                               {\r
+                                       iframe.$.contentWindow.focus();\r
+                               });\r
+                               container.append( focusGrabber );\r
+\r
+                               // Override focus handler on field.\r
+                               field.focus = function()\r
+                               {\r
+                                       focusGrabber.focus();\r
+                                       this.fire( 'focus' );\r
+                               };\r
+                       }\r
+\r
                        field.getInputElement = function(){ return iframe; };\r
 \r
                        // Force container to scale in IE.\r
@@ -165,16 +193,13 @@ CKEDITOR.dialog.add( 'paste', function( editor )
                                                html : '',\r
                                                focus : function()\r
                                                {\r
-                                                       var win = this.getInputElement().$.contentWindow,\r
-                                                                body = win && win.document.body;\r
+                                                       var win = this.getInputElement().$.contentWindow;\r
 \r
                                                        // #3291 : JAWS needs the 500ms delay to detect that the editor iframe\r
                                                        // iframe is no longer editable. So that it will put the focus into the\r
                                                        // Paste from Word dialog's editable area instead.\r
                                                        setTimeout( function()\r
                                                        {\r
-                                                               // Reactivate design mode for IE to make the cursor blinking.\r
-                                                               CKEDITOR.env.ie && body && ( body.contentEditable = "true" );\r
                                                                win.focus();\r
                                                        }, 500 );\r
                                                }\r