RichText/Archived/Rooster/Rooster.gcomp/Support/node_modules/roosterjs/dist/rooster-amd.js
/**
 * Given a node and container block, identify the first/last leaf node
 * A leaf node is defined as deepest first/last node in a block
 * i.e. &lt;div&gt;&lt;span style="font-family: Arial"&gt;abc&lt;/span&gt;&lt;/div&gt;, abc is the head leaf of the block
 * Often &lt;br&gt; or a child &lt;div&gt; is used to create a block. In that case, the leaf after the sibling div or br should be the head leaf
 * i.e. &lt;div&gt;123&lt;br&gt;abc&lt;/div&gt;, abc is the head of a block because of a previous sibling &lt;br&gt;
 * i.e. &lt;div&gt;&lt;div&gt;123&lt;/div&gt;abc&lt;/div&gt;, abc is also the head of a block because of a previous sibling &lt;div&gt;
 */
Given a node and container block, identify the first/last leaf node
A leaf node is defined as deepest first/last node in a block
i.e.
Given a node and container block identify the first / last leaf node A leaf node is defined as deepest first / last node in a block i . e .
function findHeadTailLeafNode(node, containerBlockNode, isTail) {
    var result = node;
    if (getTagOfNode_1.default(result) == 'BR' && isTail) {
        return result;
    }
    while (result) {
        var sibling = node;
        while (!(sibling = isTail ? node.nextSibling : node.previousSibling)) {
            node = node.parentNode;
            if (node == containerBlockNode) {
                return result;
            }
        }
        while (sibling) {
            if (isBlockElement_1.default(sibling)) {
                return result;
            }
            else if (getTagOfNode_1.default(sibling) == 'BR') {
                return isTail ? sibling : result;
            }
            node = sibling;
            sibling = isTail ? node.firstChild : node.lastChild;
        }
        result = node;
    }
    return result;
}
function findHeadTailLeafNode ( node , containerBlockNode , isTail ) { var result = node ; if ( getTagOfNode_1 . default ( result ) == 'BR' && isTail ) { return result ; } while ( result ) { var sibling = node ; while ( ! ( sibling = isTail ? node . nextSibling : node . previousSibling ) ) { node = node . parentNode ; if ( node == containerBlockNode ) { return result ; } } while ( sibling ) { if ( isBlockElement_1 . default ( sibling ) ) { return result ; } else if ( getTagOfNode_1 . default ( sibling ) == 'BR' ) { return isTail ? sibling : result ; } node = sibling ; sibling = isTail ? node . firstChild : node . lastChild ; } result = node ; } return result ; }
Given a node and container block, identify the first/last leaf node
 A leaf node is defined as deepest first/last node in a block
 i.e.
Given a node and container block identify the first / last leaf node A leaf node is defined as deepest first / last node in a block i . e .