JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.6.5
[ckeditor.git] / _source / plugins / wysiwygarea / plugin.js
index 1b81be2..4c1b01f 100644 (file)
@@ -46,14 +46,17 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
                                selIsLocked && this.getSelection().lock();\r
 \r
+                               var that = this;\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
                                // call.\r
-                               CKEDITOR.tools.setTimeout( function()\r
+                               setTimeout( function()\r
                                   {\r
-                                          this.fire( 'saveSnapshot' );\r
-                                  }, 0, this );\r
+                                                try { that.fire( 'saveSnapshot' ); }\r
+                                                // IEs < 9 may requires a further delay to save snapshot, after pasting. (#9132)\r
+                                                catch ( e ) { setTimeout( function(){ that.fire( 'saveSnapshot' ); }, 200 ); }\r
+                                        }, 0 );\r
                        }\r
                };\r
        }\r
@@ -338,7 +341,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
        isNotWhitespace = CKEDITOR.dom.walker.whitespaces( true );\r
 \r
        // Gecko need a key event to 'wake up' the editing\r
-       // ability when document is empty.(#3864, #5781)\r
+       // ability when document is empty.(#3864)\r
        function activateEditing( editor )\r
        {\r
                var win = editor.window,\r
@@ -394,8 +397,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
                if ( CKEDITOR.env.gecko )\r
                {\r
-                       activateEditing( editor );\r
-\r
                        // Ensure bogus br could help to move cursor (out of styles) to the end of block. (#7041)\r
                        var pathBlock = path.block || path.blockLimit,\r
                                lastNode = pathBlock && pathBlock.getLast( isNotEmpty );\r
@@ -767,9 +768,12 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
                                                domDocument.getDocumentElement().addClass( domDocument.$.compatMode );\r
                                                // Override keystroke behaviors.\r
-                                               editable && domDocument.on( 'keydown', function( evt )\r
+                                               editor.on( 'key', function( evt )\r
                                                {\r
-                                                       var keyCode = evt.data.getKeystroke();\r
+                                                       if ( editor.mode != 'wysiwyg' )\r
+                                                               return;\r
+\r
+                                                       var keyCode = evt.data.keyCode;\r
 \r
                                                        // Backspace OR Delete.\r
                                                        if ( keyCode in { 8 : 1, 46 : 1 } )\r
@@ -799,9 +803,9 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
                                                                        editor.fire( 'saveSnapshot' );\r
 \r
-                                                                       evt.data.preventDefault();\r
+                                                                       evt.cancel();\r
                                                                }\r
-                                                               else\r
+                                                               else if ( range.collapsed )\r
                                                                {\r
                                                                        // Handle the following special cases: (#6217)\r
                                                                        // 1. Del/Backspace key before/after table;\r
@@ -823,7 +827,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
                                                                                editor.fire( 'saveSnapshot' );\r
 \r
-                                                                               evt.data.preventDefault();\r
+                                                                               evt.cancel();\r
                                                                        }\r
                                                                        else if ( path.blockLimit.is( 'td' ) &&\r
                                                                                          ( parent = path.blockLimit.getAscendant( 'table' ) ) &&\r
@@ -843,7 +847,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
 \r
                                                                                editor.fire( 'saveSnapshot' );\r
 \r
-                                                                               evt.data.preventDefault();\r
+                                                                               evt.cancel();\r
                                                                        }\r
 \r
                                                                }\r
@@ -865,7 +869,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                range = new CKEDITOR.dom.range( domDocument );\r
                                                                                range[ keyCode == 33 ? 'moveToElementEditStart' : 'moveToElementEditEnd']( body );\r
                                                                                range.select();\r
-                                                                               evt.data.preventDefault();\r
+                                                                               evt.cancel();\r
                                                                        }\r
                                                                }\r
 \r
@@ -1267,9 +1271,6 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                editor.addCss( 'html { height: 100% !important; }' );\r
                                editor.addCss( 'img:-moz-broken { -moz-force-broken-image-icon : 1;     min-width : 24px; min-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