RichText/Archived/Rooster/Rooster.gcomp/Support/node_modules/roosterjs/dist/rooster-amd.js
/**
 * Apply style using a styler function to the given container node in the given range
 * @param container The container node to apply style to
 * @param styler The styler function
 * @param from From position
 * @param to To position
 */
Apply style using a styler function to the given container node in the given range
@param container The container node to apply style to
@param styler The styler function
@param from From position
@param to To position
Apply style using a styler function to the given container node in the given range @param container The container node to apply style to @param styler The styler function @param from From position @param to To position
function applyTextStyle(container, styler, from, to) {
    if (from === void 0) { from = new Position_1.default(container, 0 ).normalize(); }
    if (to === void 0) { to = new Position_1.default(container, -1 ).normalize(); }
    var formatNodes = [];
    while (from && to && to.isAfter(from)) {
        var formatNode = from.node;
        var parentTag = getTagOfNode_1.default(formatNode.parentNode);
        var nextNode = getLeafSibling_1.getNextLeafSibling(container, formatNode);
        if (formatNode.nodeType == 3  && ['TR', 'TABLE'].indexOf(parentTag) < 0) {
            if (formatNode == to.node && !to.isAtEnd) {
                formatNode = splitTextNode_1.default(formatNode, to.offset, true );
            }
            if (from.offset > 0) {
                formatNode = splitTextNode_1.default(formatNode, from.offset, false );
            }
            formatNodes.push(formatNode);
        }
        from = nextNode && new Position_1.default(nextNode, 0 );
    }
    if (formatNodes.length > 0) {
        if (formatNodes.every(function (node) { return node.parentNode == formatNodes[0].parentNode; })) {
            var newNode_1 = formatNodes.shift();
            formatNodes.forEach(function (node) {
                newNode_1.nodeValue += node.nodeValue;
                node.parentNode.removeChild(node);
            });
            formatNodes = [newNode_1];
        }
        formatNodes.forEach(function (node) {
            while (getTagOfNode_1.default(node) != 'SPAN' &&
                STYLETAGS.indexOf(getTagOfNode_1.default(node.parentNode)) >= 0) {
                callStylerWithInnerNode(node, styler);
                node = splitParentNode_1.splitBalancedNodeRange(node);
            }
            if (getTagOfNode_1.default(node) != 'SPAN') {
                callStylerWithInnerNode(node, styler);
                node = wrap_1.default(node, 'SPAN');
            }
            styler(node);
        });
    }
}
function applyTextStyle ( container , styler , from , to ) { if ( from === void 0 ) { from = new Position_1 . default ( container , 0 ) . normalize ( ) ; } if ( to === void 0 ) { to = new Position_1 . default ( container , - 1 ) . normalize ( ) ; } var formatNodes = [ ] ; while ( from && to && to . isAfter ( from ) ) { var formatNode = from . node ; var parentTag = getTagOfNode_1 . default ( formatNode . parentNode ) ; var nextNode = getLeafSibling_1 . getNextLeafSibling ( container , formatNode ) ; if ( formatNode . nodeType == 3 && [ 'TR' , 'TABLE' ] . indexOf ( parentTag ) < 0 ) { if ( formatNode == to . node && ! to . isAtEnd ) { formatNode = splitTextNode_1 . default ( formatNode , to . offset , true ) ; } if ( from . offset > 0 ) { formatNode = splitTextNode_1 . default ( formatNode , from . offset , false ) ; } formatNodes . push ( formatNode ) ; } from = nextNode && new Position_1 . default ( nextNode , 0 ) ; } if ( formatNodes . length > 0 ) { if ( formatNodes . every ( function ( node ) { return node . parentNode == formatNodes [ 0 ] . parentNode ; } ) ) { var newNode_1 = formatNodes . shift ( ) ; formatNodes . forEach ( function ( node ) { newNode_1 . nodeValue += node . nodeValue ; node . parentNode . removeChild ( node ) ; } ) ; formatNodes = [ newNode_1 ] ; } formatNodes . forEach ( function ( node ) { while ( getTagOfNode_1 . default ( node ) != 'SPAN' && STYLETAGS . indexOf ( getTagOfNode_1 . default ( node . parentNode ) ) >= 0 ) { callStylerWithInnerNode ( node , styler ) ; node = splitParentNode_1 . splitBalancedNodeRange ( node ) ; } if ( getTagOfNode_1 . default ( node ) != 'SPAN' ) { callStylerWithInnerNode ( node , styler ) ; node = wrap_1 . default ( node , 'SPAN' ) ; } styler ( node ) ; } ) ; } }
Apply style using a styler function to the given container node in the given range
 @param container The container node to apply style to
 @param styler The styler function
 @param from From position
 @param to To position
Apply style using a styler function to the given container node in the given range @param container The container node to apply style to @param styler The styler function @param from From position @param to To position
/* Begin */ /* End */ // The code below modifies DOM. Need to get the next sibling first otherwise you won't be able to reliably get a good next sibling node /* Text */ /*returnFirstPart*/ /*returnFirstPart*/ /* Begin */ // When apply style within style tags like B/I/U/..., we split the tag and apply outside them // So that the inner style tag such as U, STRIKE can inherit the style we added