- var selection = window.getSelection();\r
-\r
- if(selection.getRangeAt(0).collapsed) {\r
- \r
- } else {\r
- var textNodeIdx;\r
- var parent = $(selection.anchorNode).parent();\r
- var offsetStart = selection.anchorOffset;\r
- var offsetEnd = selection.focusOffset;\r
+ var selection = window.getSelection(),\r
+ $anchorNode = $(selection.anchorNode),\r
+ $focusNode = $(selection.focusNode);\r
+ \r
+ \r
+ if(!selection.isCollapsed && $anchorNode.parent()[0] === $focusNode.parent()[0]) {\r
+ var textNodeIdx,\r
+ parent = $anchorNode.parent(),\r
+ parentContents = parent.contents(),\r
+ offsetStart = selection.anchorOffset,\r
+ offsetEnd = selection.focusOffset;\r