tinymce.full.js
function (w3c) {
        var self = this, selection, rng, elm, doc, ieRng, evt;

        function tryCompareBoundaryPoints(how, sourceRange, destinationRange) {
          try {
            return sourceRange.compareBoundaryPoints(how, destinationRange);
          } catch (ex) {
            // Gecko throws wrong document exception if the range points
            // to nodes that where removed from the dom #6690
            // Browsers should mutate existing DOMRange instances so that they always point
            // to something in the document this is not the case in Gecko works fine in IE/WebKit/Blink
            // For performance reasons just return -1
            return -1;
          }
        }

        if (!self.win) {
          return null;
        }

        doc = self.win.document;

        if (typeof doc === 'undefined' || doc === null) {
          return null;
        }

        // Use last rng passed from FocusManager if it's available this enables
        // calls to editor.selection.getStart() to work when caret focus is lost on IE
        if (!w3c && self.lastFocusBookmark) {
          var bookmark = self.lastFocusBookmark;

          // Convert bookmark to range IE 11 fix
          if (bookmark.startContainer) {
            rng = doc.createRange();
            rng.setStart(bookmark.startContainer, bookmark.startOffset);
            rng.setEnd(bookmark.endContainer, bookmark.endOffset);
          } else {
            rng = bookmark;
          }

          return rng;
        }

        // Found tridentSel object then we need to use that one
        if (w3c && self.tridentSel) {
          return self.tridentSel.getRangeAt(0);
        }

        try {
          if ((selection = self.getSel())) {
            if (selection.rangeCount > 0) {
              rng = selection.getRangeAt(0);
            } else {
              rng = selection.createRange ? selection.createRange() : doc.createRange();
            }
          }
        } catch (ex) {
          // IE throws unspecified error here if TinyMCE is placed in a frame/iframe
        }

        evt = self.editor.fire('GetSelectionRange', { range: rng });
        if (evt.range !== rng) {
          return evt.range;
        }

        // We have W3C ranges and it's IE then fake control selection since IE9 doesn't handle that correctly yet
        // IE 11 doesn't support the selection object so we check for that as well
        if (isIE && rng && rng.setStart && doc.selection) {
          try {
            // IE will sometimes throw an exception here
            ieRng = doc.selection.createRange();
          } catch (ex) {
            // Ignore
          }

          if (ieRng && ieRng.item) {
            elm = ieRng.item(0);
            rng = doc.createRange();
            rng.setStartBefore(elm);
            rng.setEndAfter(elm);
          }
        }

        // No range found then create an empty one
        // This can occur when the editor is placed in a hidden container element on Gecko
        // Or on IE when there was an exception
        if (!rng) {
          rng = doc.createRange ? doc.createRange() : doc.body.createTextRange();
        }

        // If range is at start of document then move it to start of body
        if (rng.setStart && rng.startContainer.nodeType === 9 && rng.collapsed) {
          elm = self.dom.getRoot();
          rng.setStart(elm, 0);
          rng.setEnd(elm, 0);
        }

        if (self.selectedRange && self.explicitRange) {
          if (tryCompareBoundaryPoints(rng.START_TO_START, rng, self.selectedRange) === 0 &&
            tryCompareBoundaryPoints(rng.END_TO_END, rng, self.selectedRange) === 0) {
            // Safari, Opera and Chrome only ever select text which causes the range to change.
            // This lets us use the originally set range if the selection hasn't been changed by the user.
            rng = self.explicitRange;
          } else {
            self.selectedRange = null;
            self.explicitRange = null;
          }
        }

        return rng;
      }
function (w3c) {
        var self = this, selection, rng, elm, doc, ieRng, evt;

        function tryCompareBoundaryPoints(how, sourceRange, destinationRange) {
          try {
            return sourceRange.compareBoundaryPoints(how, destinationRange);
          } catch (ex) {
            // Gecko throws wrong document exception if the range points
            // to nodes that where removed from the dom #6690
            // Browsers should mutate existing DOMRange instances so that they always point
            // to something in the document this is not the case in Gecko works fine in IE/WebKit/Blink
            // For performance reasons just return -1
            return -1;
          }
        }

        if (!self.win) {
          return null;
        }

        doc = self.win.document;

        if (typeof doc === 'undefined' || doc === null) {
          return null;
        }

        // Use last rng passed from FocusManager if it's available this enables
        // calls to editor.selection.getStart() to work when caret focus is lost on IE
        if (!w3c && self.lastFocusBookmark) {
          var bookmark = self.lastFocusBookmark;

          // Convert bookmark to range IE 11 fix
          if (bookmark.startContainer) {
            rng = doc.createRange();
            rng.setStart(bookmark.startContainer, bookmark.startOffset);
            rng.setEnd(bookmark.endContainer, bookmark.endOffset);
          } else {
            rng = bookmark;
          }

          return rng;
        }

        // Found tridentSel object then we need to use that one
        if (w3c && self.tridentSel) {
          return self.tridentSel.getRangeAt(0);
        }

        try {
          if ((selection = self.getSel())) {
            if (selection.rangeCount > 0) {
              rng = selection.getRangeAt(0);
            } else {
              rng = selection.createRange ? selection.createRange() : doc.createRange();
            }
          }
        } catch (ex) {
          // IE throws unspecified error here if TinyMCE is placed in a frame/iframe
        }

        evt = self.editor.fire('GetSelectionRange', { range: rng });
        if (evt.range !== rng) {
          return evt.range;
        }

        // We have W3C ranges and it's IE then fake control selection since IE9 doesn't handle that correctly yet
        // IE 11 doesn't support the selection object so we check for that as well
        if (isIE && rng && rng.setStart && doc.selection) {
          try {
            // IE will sometimes throw an exception here
            ieRng = doc.selection.createRange();
          } catch (ex) {
            // Ignore
          }

          if (ieRng && ieRng.item) {
            elm = ieRng.item(0);
            rng = doc.createRange();
            rng.setStartBefore(elm);
            rng.setEndAfter(elm);
          }
        }

        // No range found then create an empty one
        // This can occur when the editor is placed in a hidden container element on Gecko
        // Or on IE when there was an exception
        if (!rng) {
          rng = doc.createRange ? doc.createRange() : doc.body.createTextRange();
        }

        // If range is at start of document then move it to start of body
        if (rng.setStart && rng.startContainer.nodeType === 9 && rng.collapsed) {
          elm = self.dom.getRoot();
          rng.setStart(elm, 0);
          rng.setEnd(elm, 0);
        }

        if (self.selectedRange && self.explicitRange) {
          if (tryCompareBoundaryPoints(rng.START_TO_START, rng, self.selectedRange) === 0 &&
            tryCompareBoundaryPoints(rng.END_TO_END, rng, self.selectedRange) === 0) {
            // Safari, Opera and Chrome only ever select text which causes the range to change.
            // This lets us use the originally set range if the selection hasn't been changed by the user.
            rng = self.explicitRange;
          } else {
            self.selectedRange = null;
            self.explicitRange = null;
          }
        }

        return rng;
      }
function ( w3c ) { var self = this , selection , rng , elm , doc , ieRng , evt ; function tryCompareBoundaryPoints ( how , sourceRange , destinationRange ) { try { return sourceRange . compareBoundaryPoints ( how , destinationRange ) ; } catch ( ex ) { // Gecko throws wrong document exception if the range points // to nodes that where removed from the dom #6690 // Browsers should mutate existing DOMRange instances so that they always point // to something in the document this is not the case in Gecko works fine in IE/WebKit/Blink // For performance reasons just return -1 return - 1 ; } } if ( ! self . win ) { return null ; } doc = self . win . document ; if ( typeof doc === 'undefined' || doc === null ) { return null ; } // Use last rng passed from FocusManager if it's available this enables // calls to editor.selection.getStart() to work when caret focus is lost on IE if ( ! w3c && self . lastFocusBookmark ) { var bookmark = self . lastFocusBookmark ; // Convert bookmark to range IE 11 fix if ( bookmark . startContainer ) { rng = doc . createRange ( ) ; rng . setStart ( bookmark . startContainer , bookmark . startOffset ) ; rng . setEnd ( bookmark . endContainer , bookmark . endOffset ) ; } else { rng = bookmark ; } return rng ; } // Found tridentSel object then we need to use that one if ( w3c && self . tridentSel ) { return self . tridentSel . getRangeAt ( 0 ) ; } try { if ( ( selection = self . getSel ( ) ) ) { if ( selection . rangeCount > 0 ) { rng = selection . getRangeAt ( 0 ) ; } else { rng = selection . createRange ? selection . createRange ( ) : doc . createRange ( ) ; } } } catch ( ex ) { // IE throws unspecified error here if TinyMCE is placed in a frame/iframe } evt = self . editor . fire ( 'GetSelectionRange' , { range : rng } ) ; if ( evt . range !== rng ) { return evt . range ; } // We have W3C ranges and it's IE then fake control selection since IE9 doesn't handle that correctly yet // IE 11 doesn't support the selection object so we check for that as well if ( isIE && rng && rng . setStart && doc . selection ) { try { // IE will sometimes throw an exception here ieRng = doc . selection . createRange ( ) ; } catch ( ex ) { // Ignore } if ( ieRng && ieRng . item ) { elm = ieRng . item ( 0 ) ; rng = doc . createRange ( ) ; rng . setStartBefore ( elm ) ; rng . setEndAfter ( elm ) ; } } // No range found then create an empty one // This can occur when the editor is placed in a hidden container element on Gecko // Or on IE when there was an exception if ( ! rng ) { rng = doc . createRange ? doc . createRange ( ) : doc . body . createTextRange ( ) ; } // If range is at start of document then move it to start of body if ( rng . setStart && rng . startContainer . nodeType === 9 && rng . collapsed ) { elm = self . dom . getRoot ( ) ; rng . setStart ( elm , 0 ) ; rng . setEnd ( elm , 0 ) ; } if ( self . selectedRange && self . explicitRange ) { if ( tryCompareBoundaryPoints ( rng . START_TO_START , rng , self . selectedRange ) === 0 && tryCompareBoundaryPoints ( rng . END_TO_END , rng , self . selectedRange ) === 0 ) { // Safari, Opera and Chrome only ever select text which causes the range to change. // This lets us use the originally set range if the selection hasn't been changed by the user. rng = self . explicitRange ; } else { self . selectedRange = null ; self . explicitRange = null ; } } return rng ; }
Returns the browsers internal range object.

@method getRng
@param {Boolean} w3c Forces a compatible W3C range on IE.
@return {Range} Internal browser range object.
@see http://www.quirksmode.org/dom/range_intro.html
@see http://www.dotvoid.com/2001/03/using-the-range-object-in-mozilla/
Returns the browsers internal range object .