&& node.getName() in CKEDITOR.dtd.$removeEmpty;\r
}\r
\r
+ function singletonBlock( node )\r
+ {\r
+ var body = range.document.getBody();\r
+ return !node.is( 'body' ) && body.getChildCount() == 1;\r
+ }\r
+\r
var start = range.startContainer,\r
offset = range.startOffset;\r
\r
\r
// 1. Empty inline element. <span>^</span>\r
// 2. Adjoin to inline element. <p><strong>text</strong>^</p>\r
- return !CKEDITOR.tools.trim( start.getHtml() ) ? isInlineCt( start ) : isInlineCt( start.getChild( offset - 1 ) ) || isInlineCt( start.getChild( offset ) );\r
+ // 3. The only empty block in document. <body><p>^</p></body> (#7222)\r
+ return !CKEDITOR.tools.trim( start.getHtml() ) ? isInlineCt( start ) || singletonBlock( start )\r
+ : isInlineCt( start.getChild( offset - 1 ) ) || isInlineCt( start.getChild( offset ) );\r
}\r
\r
var selectAllCmd =\r
{\r
modes : { wysiwyg : 1, source : 1 },\r
+ readOnly : CKEDITOR.env.ie || CKEDITOR.env.webkit,\r
exec : function( editor )\r
{\r
switch ( editor.mode )\r
});\r
\r
editor.selectionChange = checkSelectionChangeTimeout;\r
+\r
+ // IE9 might cease to work if there's an object selection inside the iframe (#7639).\r
+ CKEDITOR.env.ie9Compat && editor.on( 'destroy', function()\r
+ {\r
+ var sel = editor.getSelection();\r
+ sel && sel.getNative().clear();\r
+ }, null, null, 9 );\r
}\r
});\r
\r
};\r
\r
var styleObjectElements =\r
- {\r
- img:1,hr:1,li:1,table:1,tr:1,td:1,th:1,embed:1,object:1,ol:1,ul:1,\r
- a:1, input:1, form:1, select:1, textarea:1, button:1, fieldset:1, th:1, thead:1, tfoot:1\r
- };\r
+ {\r
+ img:1,hr:1,li:1,table:1,tr:1,td:1,th:1,embed:1,object:1,ol:1,ul:1,\r
+ a:1,input:1,form:1,select:1,textarea:1,button:1,fieldset:1,thead:1,tfoot:1\r
+ };\r
\r
CKEDITOR.dom.selection.prototype =\r
{\r
return cache.selectedElement = ( node ? new CKEDITOR.dom.element( node ) : null );\r
},\r
\r
+ /**\r
+ * Retrieves the text contained within the range, empty string is returned for non-text selection.\r
+ * @returns {String} string of text within the current selection.\r
+ * @since 3.6.1\r
+ * @example\r
+ * var text = editor.getSelectedText();\r
+ * alert( text );\r
+ */\r
+ getSelectedText : function()\r
+ {\r
+ var cache = this._.cache;\r
+ if ( cache.selectedText !== undefined )\r
+ return cache.selectedText;\r
+\r
+ var text = '',\r
+ nativeSel = this.getNative();\r
+ if ( this.getType() == CKEDITOR.SELECTION_TEXT )\r
+ text = CKEDITOR.env.ie ? nativeSel.createRange().text : nativeSel.toString();\r
+\r
+ return ( cache.selectedText = text );\r
+ },\r
+\r
lock : function()\r
{\r
// Call all cacheable function.\r
this.getRanges();\r
this.getStartElement();\r
this.getSelectedElement();\r
+ this.getSelectedText();\r
\r
// The native selection is not available when locked.\r
this._.cache.nativeSel = {};\r