JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.5.3
[ckeditor.git] / _source / plugins / wysiwygarea / plugin.js
index ff4a80e..c71f040 100644 (file)
@@ -313,9 +313,13 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                var win = editor.window,\r
                        doc = editor.document,\r
                        body = editor.document.getBody(),\r
+                       bodyFirstChild = body.getFirst(),\r
                        bodyChildsNum = body.getChildren().count();\r
 \r
-               if ( !bodyChildsNum || ( bodyChildsNum == 1&& body.getFirst().hasAttribute( '_moz_editor_bogus_node' ) ) )\r
+               if ( !bodyChildsNum\r
+                       || bodyChildsNum == 1\r
+                               && bodyFirstChild.type == CKEDITOR.NODE_ELEMENT\r
+                               && bodyFirstChild.hasAttribute( '_moz_editor_bogus_node' ) )\r
                {\r
                        restoreDirty( editor );\r
 \r
@@ -362,8 +366,14 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        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
-                       if ( pathBlock && !pathBlock.getBogus() )\r
+                       var pathBlock = path.block || path.blockLimit,\r
+                               lastNode = pathBlock && pathBlock.getLast( isNotEmpty );\r
+\r
+                       // In case it's not ended with block element and doesn't have bogus yet. (#7467)\r
+                       if ( pathBlock\r
+                                       && !( lastNode && lastNode.type == CKEDITOR.NODE_ELEMENT && lastNode.isBlockBoundary() )\r
+                                       && !pathBlock.is( 'pre' )\r
+                                       && !pathBlock.getBogus() )\r
                        {\r
                                editor.fire( 'updateSnapshot' );\r
                                restoreDirty( editor );\r
@@ -418,13 +428,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                        }\r
 \r
                        range.select();\r
-                       // Notify non-IE that selection has changed.\r
-                       if ( !CKEDITOR.env.ie )\r
-                       {\r
-                               // Make sure next selection change is correct.  (#6811)\r
-                               editor.forceNextSelectionCheck();\r
-                               editor.selectionChange();\r
-                       }\r
+                       // Cancel this selection change in favor of the next (correct).  (#6811)\r
+                       evt.cancel();\r
                }\r
 \r
                // All browsers are incapable to moving cursor out of certain non-exitable\r
@@ -687,6 +692,8 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                // Webkit: avoid from editing form control elements content.\r
                                                if ( CKEDITOR.env.webkit )\r
                                                {\r
+                                                       // Mark that cursor will right blinking (#7113).\r
+                                                       domDocument.on( 'mousedown', function() { wasFocused = 1; } );\r
                                                        // Prevent from tick checkbox/radiobox/select\r
                                                        domDocument.on( 'click', function( ev )\r
                                                        {\r
@@ -807,6 +814,30 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                        }\r
                                                                } );\r
                                                        }\r
+\r
+                                                       // Prevent IE from leaving new paragraph after deleting all contents in body. (#6966)\r
+                                                       editor.config.enterMode != CKEDITOR.ENTER_P\r
+                                                               && domDocument.on( 'selectionchange', function()\r
+                                                               {\r
+                                                                       var body = domDocument.getBody(),\r
+                                                                               range = editor.getSelection().getRanges()[ 0 ];\r
+\r
+                                                                       if ( body.getHtml().match( /^<p>&nbsp;<\/p>$/i )\r
+                                                                               && range.startContainer.equals( body ) )\r
+                                                                       {\r
+                                                                               // Avoid the ambiguity from a real user cursor position.\r
+                                                                               setTimeout( function ()\r
+                                                                               {\r
+                                                                                       range = editor.getSelection().getRanges()[ 0 ];\r
+                                                                                       if ( !range.startContainer.equals ( 'body' ) )\r
+                                                                                       {\r
+                                                                                               body.getFirst().remove( 1 );\r
+                                                                                               range.moveToElementEditEnd( body );\r
+                                                                                               range.select( 1 );\r
+                                                                                       }\r
+                                                                               }, 0 );\r
+                                                                       }\r
+                                                               });\r
                                                }\r
 \r
                                                // Adds the document body as a context menu target.\r
@@ -902,6 +933,7 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                        loadData : function( data )\r
                                                        {\r
                                                                isLoadingData = true;\r
+                                                               editor._.dataStore = { id : 1 };\r
 \r
                                                                var config = editor.config,\r
                                                                        fullPage = config.fullPage,\r
@@ -981,6 +1013,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                                '</html>';\r
                                                                }\r
 \r
+                                                               // Distinguish bogus to normal BR at the end of document for Mozilla. (#5293).\r
+                                                               if ( CKEDITOR.env.gecko )\r
+                                                                       data = data.replace( /<br \/>(?=\s*<\/(:?html|body)>)/, '$&<br type="_moz" />' );\r
+\r
                                                                data += activationScript;\r
 \r
 \r
@@ -1000,6 +1036,10 @@ For licensing, see LICENSE.html or http://ckeditor.com/license
                                                                        ? doc.getDocumentElement().getOuterHtml()\r
                                                                        : doc.getBody().getHtml();\r
 \r
+                                                               // BR at the end of document is bogus node for Mozilla. (#5293).\r
+                                                               if ( CKEDITOR.env.gecko )\r
+                                                                       data = data.replace( /<br>(?=\s*(:?$|<\/body>))/, '' );\r
+\r
                                                                if ( editor.dataProcessor )\r
                                                                        data = editor.dataProcessor.toDataFormat( data, fixForBody );\r
 \r
@@ -1236,14 +1276,12 @@ CKEDITOR.config.disableObjectResizing = false;
 CKEDITOR.config.disableNativeTableHandles = true;\r
 \r
 /**\r
- * Disables the built-in spell checker while typing natively available in the\r
- * browser (currently Firefox and Safari only).<br /><br />\r
+ * Disables the built-in words spell checker if browser provides one.<br /><br />\r
  *\r
- * Even if word suggestions will not appear in the CKEditor context menu, this\r
- * feature is useful to help quickly identifying misspelled words.<br /><br />\r
+ * <strong>Note:</strong> Although word suggestions provided by browsers (natively) will not appear in CKEditor's default context menu,\r
+ * users can always reach the native context menu by holding the <em>Ctrl</em> key when right-clicking if {@link CKEDITOR.config.browserContextMenuOnCtrl}\r
+ * is enabled or you're simply not using the context menu plugin.\r
  *\r
- * This setting is currently compatible with Firefox only due to limitations in\r
- * other browsers.\r
  * @type Boolean\r
  * @default true\r
  * @example\r