RichText/Archived/Rooster/Rooster.gcomp/Support/node_modules/roosterjs/dist/rooster-amd.js
/**
 * Gets or creates the specified list
 */
Gets or creates the specified list
Gets or creates the specified list
function recurringGetOrCreateListAtNode(node, level, listMetadata) {
    var parent = null;
    var possibleList;
    if (level == 1) {
        possibleList = getRealPreviousSibling(node);
    }
    else {
        parent = recurringGetOrCreateListAtNode(node, level - 1, null);
        possibleList = parent.lastChild;
    }
    if (possibleList && possibleList.nodeType == 1 ) {
        var tag = roosterjs_editor_dom_1.getTagOfNode(possibleList);
        if (tag == 'UL' || tag == 'OL') {
            return possibleList;
        }
    }
    var newList = node.ownerDocument.createElement(listMetadata ? listMetadata.tagName : 'UL');
    if (level == 1) {
        node.parentNode.insertBefore(newList, node);
    }
    else {
        parent.appendChild(newList);
    }
    return newList;
}
function recurringGetOrCreateListAtNode ( node , level , listMetadata ) { var parent = null ; var possibleList ; if ( level == 1 ) { possibleList = getRealPreviousSibling ( node ) ; } else { parent = recurringGetOrCreateListAtNode ( node , level - 1 , null ) ; possibleList = parent . lastChild ; } if ( possibleList && possibleList . nodeType == 1 ) { var tag = roosterjs_editor_dom_1 . getTagOfNode ( possibleList ) ; if ( tag == 'UL' || tag == 'OL' ) { return possibleList ; } } var newList = node . ownerDocument . createElement ( listMetadata ? listMetadata . tagName : 'UL' ) ; if ( level == 1 ) { node . parentNode . insertBefore ( newList , node ) ; } else { parent . appendChild ( newList ) ; } return newList ; }
Gets or creates the specified list
Gets or creates the specified list
// Root case, we'll check if the list is the previous sibling of the node // If we get here, we are looking for level 2 or deeper... get the upper list // and check if the last element is a list // Check the element that we got and verify that it is a list /* Element */ // We have a list.. use it // If we get here, it means we don't have a list and we need to create one // this code path will always create new lists as UL lists // For level 1, we'll insert the list beofre the node // Any level 2 or above, we insert the list as the last // child of the upper level list