src/modules/inactive/rangy-textcommands.js
function(textNodes, range) {
            log.group("postApply");
            var firstNode = textNodes[0], lastNode = textNodes[textNodes.length - 1];

            var merges = [], currentMerge;

            var rangeStartNode = firstNode, rangeEndNode = lastNode;
            var rangeStartOffset = 0, rangeEndOffset = lastNode.length;

            var textNode, precedingTextNode;

            for (var i = 0, len = textNodes.length; i < len; ++i) {
                textNode = textNodes[i];
                precedingTextNode = getAdjacentMergeableTextNode(textNode, false);
                log.debug("Checking for merge. text node: " + textNode.data + ", preceding: " + (precedingTextNode ? precedingTextNode.data : null));
                if (precedingTextNode) {
                    if (!currentMerge) {
                        currentMerge = new Merge(precedingTextNode);
                        merges.push(currentMerge);
                    }
                    currentMerge.textNodes.push(textNode);
                    if (textNode === firstNode) {
                        rangeStartNode = currentMerge.firstTextNode;
                        rangeStartOffset = rangeStartNode.length;
                    }
                    if (textNode === lastNode) {
                        rangeEndNode = currentMerge.firstTextNode;
                        rangeEndOffset = currentMerge.getLength();
                    }
                } else {
                    currentMerge = null;
                }
            }

            // Test whether the first node after the range needs merging
            var nextTextNode = getAdjacentMergeableTextNode(lastNode, true);

            if (nextTextNode) {
                if (!currentMerge) {
                    currentMerge = new Merge(lastNode);
                    merges.push(currentMerge);
                }
                currentMerge.textNodes.push(nextTextNode);
            }

            // Do the merges
            if (merges.length) {
                log.info("Merging. Merges:", merges);
                for (i = 0, len = merges.length; i < len; ++i) {
                    merges[i].doMerge();
                }
                log.info(rangeStartNode.nodeValue, rangeStartOffset, rangeEndNode.nodeValue, rangeEndOffset);

                // Set the range boundaries
                range.setStart(rangeStartNode, rangeStartOffset);
                range.setEnd(rangeEndNode, rangeEndOffset);
            }
            log.groupEnd();
        }
function(textNodes, range) {
            log.group("postApply");
            var firstNode = textNodes[0], lastNode = textNodes[textNodes.length - 1];

            var merges = [], currentMerge;

            var rangeStartNode = firstNode, rangeEndNode = lastNode;
            var rangeStartOffset = 0, rangeEndOffset = lastNode.length;

            var textNode, precedingTextNode;

            for (var i = 0, len = textNodes.length; i < len; ++i) {
                textNode = textNodes[i];
                precedingTextNode = getAdjacentMergeableTextNode(textNode, false);
                log.debug("Checking for merge. text node: " + textNode.data + ", preceding: " + (precedingTextNode ? precedingTextNode.data : null));
                if (precedingTextNode) {
                    if (!currentMerge) {
                        currentMerge = new Merge(precedingTextNode);
                        merges.push(currentMerge);
                    }
                    currentMerge.textNodes.push(textNode);
                    if (textNode === firstNode) {
                        rangeStartNode = currentMerge.firstTextNode;
                        rangeStartOffset = rangeStartNode.length;
                    }
                    if (textNode === lastNode) {
                        rangeEndNode = currentMerge.firstTextNode;
                        rangeEndOffset = currentMerge.getLength();
                    }
                } else {
                    currentMerge = null;
                }
            }

            // Test whether the first node after the range needs merging
            var nextTextNode = getAdjacentMergeableTextNode(lastNode, true);

            if (nextTextNode) {
                if (!currentMerge) {
                    currentMerge = new Merge(lastNode);
                    merges.push(currentMerge);
                }
                currentMerge.textNodes.push(nextTextNode);
            }

            // Do the merges
            if (merges.length) {
                log.info("Merging. Merges:", merges);
                for (i = 0, len = merges.length; i < len; ++i) {
                    merges[i].doMerge();
                }
                log.info(rangeStartNode.nodeValue, rangeStartOffset, rangeEndNode.nodeValue, rangeEndOffset);

                // Set the range boundaries
                range.setStart(rangeStartNode, rangeStartOffset);
                range.setEnd(rangeEndNode, rangeEndOffset);
            }
            log.groupEnd();
        }
function ( textNodes , range ) { log . group ( "postApply" ) ; var firstNode = textNodes [ 0 ] , lastNode = textNodes [ textNodes . length - 1 ] ; var merges = [ ] , currentMerge ; var rangeStartNode = firstNode , rangeEndNode = lastNode ; var rangeStartOffset = 0 , rangeEndOffset = lastNode . length ; var textNode , precedingTextNode ; for ( var i = 0 , len = textNodes . length ; i < len ; ++ i ) { textNode = textNodes [ i ] ; precedingTextNode = getAdjacentMergeableTextNode ( textNode , false ) ; log . debug ( "Checking for merge. text node: " + textNode . data + ", preceding: " + ( precedingTextNode ? precedingTextNode . data : null ) ) ; if ( precedingTextNode ) { if ( ! currentMerge ) { currentMerge = new Merge ( precedingTextNode ) ; merges . push ( currentMerge ) ; } currentMerge . textNodes . push ( textNode ) ; if ( textNode === firstNode ) { rangeStartNode = currentMerge . firstTextNode ; rangeStartOffset = rangeStartNode . length ; } if ( textNode === lastNode ) { rangeEndNode = currentMerge . firstTextNode ; rangeEndOffset = currentMerge . getLength ( ) ; } } else { currentMerge = null ; } } // Test whether the first node after the range needs merging var nextTextNode = getAdjacentMergeableTextNode ( lastNode , true ) ; if ( nextTextNode ) { if ( ! currentMerge ) { currentMerge = new Merge ( lastNode ) ; merges . push ( currentMerge ) ; } currentMerge . textNodes . push ( nextTextNode ) ; } // Do the merges if ( merges . length ) { log . info ( "Merging. Merges:" , merges ) ; for ( i = 0 , len = merges . length ; i < len ; ++ i ) { merges [ i ] . doMerge ( ) ; } log . info ( rangeStartNode . nodeValue , rangeStartOffset , rangeEndNode . nodeValue , rangeEndOffset ) ; // Set the range boundaries range . setStart ( rangeStartNode , rangeStartOffset ) ; range . setEnd ( rangeEndNode , rangeEndOffset ) ; } log . groupEnd ( ) ; }
Normalizes nodes after applying a CSS class to a Range.
Normalizes nodes after applying a CSS class to a Range .