Changeset 597
- Timestamp:
- 2007-07-31 08:33:50 (16 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
FCKeditor/trunk/editor/_source/internals/fck_gecko.js
r596 r597 65 65 66 66 var keyCode = evt.keyCode ; 67 var modKeys = { 34 : 1, 35 : 1, 39 : 1, 40 : 1 } ; 68 if ( ! modKeys[keyCode] ) 67 // ignore if positioning key is not pressed. 68 // left or up arrow keys need to be processed as well, since <a> links can be expanded in Gecko's editor 69 // when the caret moved left or up from another block element below. 70 if ( keyCode < 33 || keyCode > 40 ) 69 71 return ; 70 72 … … 78 80 var node = range.endContainer ; 79 81 82 // only perform the patched behavior if we're at the end of a text node. 80 83 if ( node.nodeType != 3 ) 81 84 return ; … … 84 87 return ; 85 88 86 // we've moved to just after the last character of a text node under an unknown tag, how to proceed? 89 // only perform the patched behavior if we're in an <a> tag, or the End key is pressed. 90 var parentTag = node.parentNode.tagName.toLowerCase() ; 91 if ( ! ( parentTag == 'a' || ( ! FCKListsLib.BlockElements[parentTag] && keyCode == 35 ) ) ) 92 return ; 93 94 // our caret has moved to just after the last character of a text node under an unknown tag, how to proceed? 87 95 // first, see if there are other text nodes by DFS walking from this text node. 88 96 // - if the DFS has scanned all nodes under my parent, then go the next step. … … 108 116 // no suitable next siblings under our grandparent! what to do next? 109 117 node = node.parentNode ; 110 if ( FCKListsLib.BlockElements[ node.tagName.toLowerCase() ] || node == FCK.EditorDocument.body ) 118 if ( FCKListsLib.BlockElements[ parentTag ] 119 || FCKListsLib.EmptyElements[ parentTag ] 120 || node == FCK.EditorDocument.body ) 111 121 { 112 122 // if our parent is a block node, move to the end of our parent. … … 116 126 else 117 127 { 118 // if our parent is not a block node, move to the end of our grandparent. 128 // things are a little bit more interesting if our parent is not a block node 129 // due to the weired ways how Gecko's caret acts... 130 131 var stopNode = node.nextSibling ; 132 133 // find out the next block/empty element at our grandparent, we'll 134 // move the caret just before it. 135 while ( stopNode ) 136 { 137 if ( stopNode.nodeType != 1 ) 138 { 139 stopNode = stopNode.nextSibling ; 140 continue ; 141 } 142 143 var stopTag = stopNode.tagName.toLowerCase() ; 144 if ( FCKListsLib.BlockElements[stopTag] || FCKListsLib.EmptyElements[stopTag] ) 145 break ; 146 stopNode = stopNode.nextSibling ; 147 } 148 119 149 // note that the dummy marker below is NEEDED, otherwise the caret's behavior will 120 150 // be broken in Gecko. 121 151 var marker = FCK.EditorDocument.createTextNode( "" ) ; 122 node.parentNode.appendChild( marker ) ; 152 if ( stopNode ) 153 node.parentNode.insertBefore( marker, stopNode ) ; 154 else 155 node.parentNode.appendChild( marker ) ; 123 156 range.setStart( marker, 0 ) ; 124 157 range.setEnd( marker, 0 ) ;