RichText/Archived/Rooster/Rooster.gcomp/Support/node_modules/roosterjs/dist/rooster-amd.js
/**
 * Convert text copied from word online into text that's workable with rooster editor
 * @param doc Document that is being pasted into editor.
 */
Convert text copied from word online into text that's workable with rooster editor
@param doc Document that is being pasted into editor.
Convert text copied from word online into text that ' s workable with rooster editor @param doc Document that is being pasted into editor .
function convertPastedContentFromWordOnline(doc) {
    sanitizeListItemContainer(doc);
    var listItemBlocks = getListItemBlocks(doc);
    listItemBlocks.forEach(function (itemBlock) {
            <ol></ol>
            <ol></ol>
            <ol></ol>
         Then we are start processing.
        flattenListBlock(doc.body, itemBlock);
         Find the node to insertBefore, which is next sibling node of the end of a listItemBlock.
        itemBlock.insertPositionNode = itemBlock.endElement.nextSibling;
        var convertedListElement;
        itemBlock.listItemContainers.forEach(function (listItemContainer) {
            var listType = getContainerListType(listItemContainer);  list type that is contained by iterator.
             Initialize processed element with propery listType if this is the first element
            if (!convertedListElement) {
                convertedListElement = doc.createElement(listType);
            }
             Get all list items(<li>) in the current iterator element.
            var currentListItems = listItemContainer.querySelectorAll('li');
            currentListItems.forEach(function (item) {
                 If item is in root level and the type of list changes then
                 insert the current list into body and then reinitialize the convertedListElement
                 Word Online is using data-aria-level to determine the the depth of the list item.
                var itemLevel = parseInt(item.getAttribute('data-aria-level'));
                 In first level list, there are cases where a consecutive list item divs may have different list type
                 When that happens we need to insert the processed elements into the document, then change the list type
                 and keep the processing going.
                if (roosterjs_editor_dom_1.getTagOfNode(convertedListElement) != listType && itemLevel == 1) {
                    insertConvertedListToDoc(convertedListElement, doc.body, itemBlock);
                    convertedListElement = doc.createElement(listType);
                }
                insertListItem(convertedListElement, item, listType, doc);
            });
        });
        insertConvertedListToDoc(convertedListElement, doc.body, itemBlock);
         Once we finish the process the list items and put them into a list.
         After inserting the processed element,
         we need to remove all the non processed node from the parent node.
        var parentContainer = itemBlock.startElement.parentNode;
        if (parentContainer) {
            itemBlock.listItemContainers.forEach(function (listItemContainer) {
                parentContainer.removeChild(listItemContainer);
            });
        }
    });
}
function convertPastedContentFromWordOnline ( doc ) { sanitizeListItemContainer ( doc ) ; var listItemBlocks = getListItemBlocks ( doc ) ; listItemBlocks . forEach ( function ( itemBlock ) { flattenListBlock ( doc . body , itemBlock ) ; itemBlock . insertPositionNode = itemBlock . endElement . nextSibling ; var convertedListElement ; itemBlock . listItemContainers . forEach ( function ( listItemContainer ) { var listType = getContainerListType ( listItemContainer ) ; if ( ! convertedListElement ) { convertedListElement = doc . createElement ( listType ) ; } var currentListItems = listItemContainer . querySelectorAll ( 'li' ) ; currentListItems . forEach ( function ( item ) { var itemLevel = parseInt ( item . getAttribute ( 'data-aria-level' ) ) ; if ( roosterjs_editor_dom_1 . getTagOfNode ( convertedListElement ) != listType && itemLevel == 1 ) { insertConvertedListToDoc ( convertedListElement , doc . body , itemBlock ) ; convertedListElement = doc . createElement ( listType ) ; } insertListItem ( convertedListElement , item , listType , doc ) ; } ) ; } ) ; insertConvertedListToDoc ( convertedListElement , doc . body , itemBlock ) ; var parentContainer = itemBlock . startElement . parentNode ; if ( parentContainer ) { itemBlock . listItemContainers . forEach ( function ( listItemContainer ) { parentContainer . removeChild ( listItemContainer ) ; } ) ; } } ) ; }
Convert text copied from word online into text that's workable with rooster editor
 @param doc Document that is being pasted into editor.
Convert text copied from word online into text that ' s workable with rooster editor @param doc Document that is being pasted into editor .
// There are cases where consecutive List Elements are seperated into different divs: // <div> //   <div> //      <ol></ol> //   </div> //   <div> //      <ol></ol> //   </div> // </div> // <div> //   <div> //      <ol></ol> //   </div> // </div> // in the above case we want to collapse the two root level div into one and unwrap the list item divs. // after the following flattening the list will become following: // // <div> //    <ol></ol> // </div> // <div> //    <ol></ol> // </div> // <div> //    <ol></ol> // </div> // Then we are start processing. // Find the node to insertBefore, which is next sibling node of the end of a listItemBlock. // list type that is contained by iterator. // Initialize processed element with propery listType if this is the first element // Get all list items(<li>) in the current iterator element. // If item is in root level and the type of list changes then // insert the current list into body and then reinitialize the convertedListElement // Word Online is using data-aria-level to determine the the depth of the list item. // In first level list, there are cases where a consecutive list item divs may have different list type // When that happens we need to insert the processed elements into the document, then change the list type // and keep the processing going. // Once we finish the process the list items and put them into a list. // After inserting the processed element, // we need to remove all the non processed node from the parent node.