src/cm/media/js/client/c_selection.js
changeset 397 eba2e55eb437
parent 341 053551f213fb
child 525 89ef5ed3c48b
--- a/src/cm/media/js/client/c_selection.js	Mon Jan 23 11:14:44 2012 +0100
+++ b/src/cm/media/js/client/c_selection.js	Fri Jan 27 11:37:22 2012 +0100
@@ -43,8 +43,16 @@
         var leftToRight = (r2.compareBoundaryPoints(2, r1) == 1) ; // 2 is for END_TO_END
 //        CY.log("leftToRight : " + leftToRight) ;
         startNode = (leftToRight) ? userSelection.anchorNode.parentNode : userSelection.focusNode.parentNode ;  
+        // GIB: when selecting amath, we should go up in the dom to find the accurate start/end Nodes
+        if (startNode.nodeName == 'mi' || startNode.nodeName == 'mo') {
+          startNode = startNode.parentElement.parentElement.parentElement.parentElement;
+        }
         innerStartNode = (leftToRight) ? userSelection.anchorNode : userSelection.focusNode ;
         endNode = (leftToRight) ? userSelection.focusNode.parentNode : userSelection.anchorNode.parentNode;
+        // GIB: when selecting amath, we should go up in the dom to find the accurate start/end Nodes
+        if (endNode.nodeName == 'mi' || endNode.nodeName == 'mo') {
+          endNode = endNode.parentElement.parentElement.parentElement.parentElement;
+        }
         innerEndNode = (leftToRight) ? userSelection.focusNode : userSelection.anchorNode;
           
         startOffset = (leftToRight) ? userSelection.anchorOffset : userSelection.focusOffset;