Ticket #3312: 3312.patch
File 3312.patch, 10.1 KB (added by , 15 years ago) |
---|
-
_source/plugins/enterkey/plugin.js
77 77 78 78 var node; 79 79 80 // If this is a block under a list item, split it as well. (#1647) 80 // 1. If this is a block under a list item, split it as well. (#1647) 81 // 2. Exist the whole list if it's the last empty first-level list item. (#3312) 81 82 if ( nextBlock ) 82 83 { 83 84 node = nextBlock.getParent(); … … 93 94 range.moveToElementEditStart( previousBlock.getNext() ); 94 95 previousBlock.move( previousBlock.getPrevious() ); 95 96 } 97 else if ( ( node = previousBlock ) && node.is( 'li' ) 98 && node.getParent().is('ul') 99 && !node.getNext() 100 && !CKEDITOR.tools.trim( node.getText() ).length ) 101 { 102 var editableElement; 103 // Locate the next content edit-able element of this node. 104 function getNextEditableElement( node ) 105 { 106 var walker = new CKEDITOR.dom.walker( node ); 107 walker.evaluator = function( toNode ){ 108 return ( !!toNode.isEditable && toNode.isEditable() ); 109 }; 110 return walker.next(); 111 } 112 113 if ( editableElement = getNextEditableElement( 114 ( node.getLast && node.getLast() )|| node ) ) 115 { 116 editableElement.scrollIntoView(); 117 range.moveToPosition( editableElement, CKEDITOR.POSITION_AFTER_START ); 118 range.select(); 119 } 96 120 121 return; 122 } 97 123 // If we have both the previous and next blocks, it means that the 98 124 // boundaries were on separated blocks, or none of them where on the 99 125 // block limits (start/end). -
_source/core/dom/element.js
5 5 6 6 /** 7 7 * @fileOverview Defines the {@link CKEDITOR.dom.element} class, which 8 * 8 * represents a DOM element. 9 9 */ 10 10 11 11 /** … … 13 13 * @constructor 14 14 * @augments CKEDITOR.dom.node 15 15 * @param {Object|String} element A native DOM element or the element name for 16 * 16 * new elements. 17 17 * @param {CKEDITOR.dom.document} [ownerDocument] The document that will contain 18 * 18 * the element in case of element creation. 19 19 * @example 20 20 * // Create a new <span> element. 21 21 * var element = new CKEDITOR.dom.element( 'span' ); … … 57 57 * Creates an instance of the {@link CKEDITOR.dom.element} class based on the 58 58 * HTML representation of an element. 59 59 * @param {String} html The element HTML. It should define only one element in 60 * 61 * 60 * the "root" level. The "root" element can have child nodes, but not 61 * siblings. 62 62 * @returns {CKEDITOR.dom.element} The element instance. 63 63 * @example 64 64 * var element = <b>CKEDITOR.dom.element.createFromHtml( '<strong class="anyclass">My element</strong>' )</b>; … … 176 176 /** 177 177 * Append a node as a child of this element. 178 178 * @param {CKEDITOR.dom.node|String} node The node or element name to be 179 * 179 * appended. 180 180 * @param {Boolean} [toStart] Indicates that the element is to be 181 * 181 * appended at the start. 182 182 * @returns {CKEDITOR.dom.node} The appended node. 183 183 * @example 184 184 * var p = new CKEDITOR.dom.element( 'p' ); … … 463 463 /** 464 464 * Gets the DTD entries for this element. 465 465 * @returns {Object} An object containing the list of elements accepted 466 * 466 * by this element. 467 467 */ 468 468 getDtd : function() 469 469 { … … 477 477 return dtd; 478 478 }, 479 479 480 getElementsByTag : CKEDITOR.dom.document.prototype.getElementsByTag, 480 getElementsByTag : function( tagName, namespace ) 481 { 482 if ( !CKEDITOR.env.ie && namespace ) 483 tagName = namespace + ':' + tagName; 484 return new CKEDITOR.dom.nodeList( this.$.getElementsByTagName( tagName ) ); 485 }, 481 486 482 487 /** 483 488 * Gets the computed tabindex for this element. … … 543 548 */ 544 549 getText : function() 545 550 { 546 return this.$.textContent || this.$.innerText; 551 return ( typeof this.$.textContent != 'undefined' )? 552 this.$.textContent : this.$.innerText; 547 553 }, 548 554 549 555 /** … … 621 627 /** 622 628 * Gets the first child node of this element. 623 629 * @returns {CKEDITOR.dom.node} The first child node or null if not 624 * 630 * available. 625 631 * @example 626 632 * var element = CKEDITOR.dom.element.createFromHtml( '<div><b>Example</b></div>' ); 627 633 * var first = <b>element.getFirst()</b>; … … 642 648 /** 643 649 * Gets the node that follows this element in its parent's child list. 644 650 * @returns {CKEDITOR.dom.node} The next node or null if not 645 * 651 * available. 646 652 * @example 647 653 * var element = CKEDITOR.dom.element.createFromHtml( '<div><b>Example</b> <i>next</i></div>' ); 648 654 * var first = <b>element.getFirst().getNext()</b>; … … 897 903 this.$.className = value; 898 904 else if ( name == 'style' ) 899 905 this.$.style.cssText = value; 900 else if ( name == 'tabindex' ) 906 else if ( name == 'tabindex' ) // Case sensitive. 901 907 this.$.tabIndex = value; 902 908 else 903 909 standard.apply( this, arguments ); … … 911 917 /** 912 918 * Sets the value of several element attributes. 913 919 * @param {Object} attributesPairs An object containing the names and 914 * 920 * values of the attributes. 915 921 * @returns {CKEDITOR.dom.element} This element instance. 916 922 * @example 917 923 * var element = CKEDITOR.dom.element.getById( 'myElement' ); … … 994 1000 /** 995 1001 * Sets the value of an element style. 996 1002 * @param {String} name The name of the style. The CSS naming notation 997 * 1003 * must be used (e.g. "background-color"). 998 1004 * @param {String} value The value to be set to the style. 999 1005 * @returns {CKEDITOR.dom.element} This element instance. 1000 1006 * @example … … 1012 1018 /** 1013 1019 * Sets the value of several element styles. 1014 1020 * @param {Object} stylesPairs An object containing the names and 1015 * 1021 * values of the styles. 1016 1022 * @returns {CKEDITOR.dom.element} This element instance. 1017 1023 * @example 1018 1024 * var element = CKEDITOR.dom.element.getById( 'myElement' ); … … 1114 1120 1115 1121 if ( !CKEDITOR.env.opera ) 1116 1122 { 1117 // Opera includes clientTop|Left into offsetTop|Left.1118 if ( !current.equals( this ) )1119 {1120 x += ( current.$.clientLeft || 0 );1121 y += ( current.$.clientTop || 0 );1122 }1123 1124 1123 var scrollElement = previous; 1125 1124 while ( scrollElement && !scrollElement.equals( current ) ) 1126 1125 { … … 1148 1147 } 1149 1148 } 1150 1149 1151 var body = this.getDocument().getBody();1152 1153 1150 // document.body is a special case when it comes to offsetTop and offsetLeft 1154 1151 // values. 1155 1152 // 1. It matters if document.body itself is a positioned element; … … 1155 1152 // 1. It matters if document.body itself is a positioned element; 1156 1153 // 2. It matters when we're in IE and the element has no positioned ancestor. 1157 1154 // Otherwise the values should be ignored. 1158 if ( body.getComputedStyle( 'position' ) != 'static' || ( CKEDITOR.env.ie && !this.getPositionedAncestor() ) )1155 if ( this.getComputedStyle( 'position' ) != 'static' || ( CKEDITOR.env.ie && !this.getPositionedAncestor() ) ) 1159 1156 { 1160 x += body.$.offsetLeft + ( body.$.clientLeft || 0 ); 1161 y += body.$.offsetTop + ( body.$.clientTop || 0 ); 1162 } 1163 1164 // In Firefox, we'll endup one pixel before the element positions, 1165 // so we must add it here. 1166 if ( CKEDITOR.env.gecko && !CKEDITOR.env.quirks ) 1167 { 1168 x += this.$.clientLeft ? 1 : 0; 1169 y += this.$.clientTop ? 1 : 0;; 1157 x += this.getDocument().getBody().$.offsetLeft; 1158 y += this.getDocument().getBody().$.offsetTop; 1170 1159 } 1171 1160 1172 1161 return { x : x, y : y }; … … 1260 1249 } 1261 1250 1262 1251 return $ && new CKEDITOR.dom.document( $.contentWindow.document ); 1263 },1264 1265 /**1266 * Copy all the attributes from one node to the other, kinda like a clone1267 * skipAttributes is an object with the attributes that must NOT be copied.1268 * @param {CKEDITOR.dom.element} dest The destination element.1269 * @param {Object} skipAttributes A dictionary of attributes to skip.1270 * @example1271 */1272 copyAttributes : function( dest, skipAttributes )1273 {1274 var attributes = this.$.attributes;1275 skipAttributes = skipAttributes || {};1276 1277 for ( var n = 0 ; n < attributes.length ; n++ )1278 {1279 var attribute = attributes[n];1280 1281 if ( attribute.specified )1282 {1283 var attrName = attribute.nodeName;1284 // We can set the type only once, so do it with the proper value, not copying it.1285 if ( attrName in skipAttributes )1286 continue;1287 1288 var attrValue = this.getAttribute( attrName );1289 if ( attrValue === null )1290 attrValue = attribute.nodeValue;1291 1292 dest.setAttribute( attrName, attrValue );1293 }1294 }1295 1296 // The style:1297 if ( this.$.style.cssText !== '' )1298 dest.$.style.cssText = this.$.style.cssText;1299 },1300 1301 /**1302 * Changes the tag name of the current element.1303 * @param {String} newTag The new tag for the element.1304 */1305 renameNode : function( newTag )1306 {1307 // If it's already correct exit here.1308 if ( this.getName() == newTag )1309 return;1310 1311 var doc = this.getDocument();1312 1313 // Create the new node.1314 var newNode = new CKEDITOR.dom.element( newTag, doc );1315 1316 // Copy all attributes.1317 this.copyAttributes( newNode );1318 1319 // Move children to the new node.1320 this.moveChildren( newNode );1321 1322 // Replace the node.1323 this.$.parentNode.replaceChild( newNode.$, this.$ );1324 newNode.$._cke_expando = this.$._cke_expando;1325 this.$ = newNode.$;1326 1252 } 1327 1253 });