tinymce.full.js
function findClosestIeRange(clientX, clientY, doc) {
      var element, rng, rects;

      element = doc.elementFromPoint(clientX, clientY);
      rng = doc.body.createTextRange();

      if (!element || element.tagName == 'HTML') {
        element = doc.body;
      }

      rng.moveToElementText(element);
      rects = Tools.toArray(rng.getClientRects());

      rects = rects.sort(function (a, b) {
        a = Math.abs(Math.max(a.top - clientY, a.bottom - clientY));
        b = Math.abs(Math.max(b.top - clientY, b.bottom - clientY));

        return a - b;
      });

      if (rects.length > 0) {
        clientY = (rects[0].bottom + rects[0].top) / 2;

        try {
          rng.moveToPoint(clientX, clientY);
          rng.collapse(true);

          return rng;
        } catch (ex) {
          // At least we tried
        }
      }

      return null;
    }
function findClosestIeRange(clientX, clientY, doc) {
      var element, rng, rects;

      element = doc.elementFromPoint(clientX, clientY);
      rng = doc.body.createTextRange();

      if (!element || element.tagName == 'HTML') {
        element = doc.body;
      }

      rng.moveToElementText(element);
      rects = Tools.toArray(rng.getClientRects());

      rects = rects.sort(function (a, b) {
        a = Math.abs(Math.max(a.top - clientY, a.bottom - clientY));
        b = Math.abs(Math.max(b.top - clientY, b.bottom - clientY));

        return a - b;
      });

      if (rects.length > 0) {
        clientY = (rects[0].bottom + rects[0].top) / 2;

        try {
          rng.moveToPoint(clientX, clientY);
          rng.collapse(true);

          return rng;
        } catch (ex) {
          // At least we tried
        }
      }

      return null;
    }
function findClosestIeRange ( clientX , clientY , doc ) { var element , rng , rects ; element = doc . elementFromPoint ( clientX , clientY ) ; rng = doc . body . createTextRange ( ) ; if ( ! element || element . tagName == 'HTML' ) { element = doc . body ; } rng . moveToElementText ( element ) ; rects = Tools . toArray ( rng . getClientRects ( ) ) ; rects = rects . sort ( function ( a , b ) { a = Math . abs ( Math . max ( a . top - clientY , a . bottom - clientY ) ) ; b = Math . abs ( Math . max ( b . top - clientY , b . bottom - clientY ) ) ; return a - b ; } ) ; if ( rects . length > 0 ) { clientY = ( rects [ 0 ] . bottom + rects [ 0 ] . top ) / 2 ; try { rng . moveToPoint ( clientX , clientY ) ; rng . collapse ( true ) ; return rng ; } catch ( ex ) { // At least we tried } } return null ; }
Finds the closest selection rect tries to get the range from that.
Finds the closest selection rect tries to get the range from that .