RichText/Archived/Rooster/Rooster.gcomp/Support/node_modules/roosterjs/dist/rooster-amd.js
/**
 * Browsers don't handle bullet/numbering list well, especially the formats when switching list statue
 * So we workaround it by always adding format to list element
 */
Browsers don't handle bullet/numbering list well, especially the formats when switching list statue
So we workaround it by always adding format to list element
Browsers don ' t handle bullet / numbering list well especially the formats when switching list statue So we workaround it by always adding format to list element
function processList(editor, command) {
    var clonedNode;
    var relativeSelectionPath;
    if (roosterjs_editor_dom_1.Browser.isChrome && command == "outdent" ) {
        var parentLINode = editor.getElementAtCursor('LI');
        if (parentLINode) {
            var currentRange = editor.getSelectionRange();
            if (currentRange.collapsed ||
                (editor.getElementAtCursor('LI', currentRange.startContainer) == parentLINode &&
                    editor.getElementAtCursor('LI', currentRange.endContainer) == parentLINode)) {
                relativeSelectionPath = roosterjs_editor_dom_1.getSelectionPath(parentLINode, currentRange);
                clonedNode = parentLINode.cloneNode(true);
            }
        }
        workaroundForChrome(editor);
    }
    var existingList = editor.getElementAtCursor('OL,UL');
    editor.getDocument().execCommand(command, false, null);
    var newParentNode;
    editor.queryElements('.' + TEMP_NODE_CLASS, function (node) {
        newParentNode = node.parentNode;
        editor.deleteNode(node);
    });
    var newList = editor.getElementAtCursor('OL,UL');
    if (newList == existingList) {
        newList = null;
    }
    if (newList && clonedNode && newParentNode) {
        if ((clonedNode instanceof HTMLElement)) {
            if (newParentNode instanceof HTMLElement && clonedNode.tagName == newParentNode.tagName) {
                newList.replaceChild(clonedNode, newParentNode);
            }
            if (relativeSelectionPath && document.body.contains(clonedNode)) {
                var newRange = roosterjs_editor_dom_1.getRangeFromSelectionPath(clonedNode, relativeSelectionPath);
                editor.select(newRange);
            }
        }
    }
    return newList;
}
function processList ( editor , command ) { var clonedNode ; var relativeSelectionPath ; if ( roosterjs_editor_dom_1 . Browser . isChrome && command == "outdent" ) { var parentLINode = editor . getElementAtCursor ( 'LI' ) ; if ( parentLINode ) { var currentRange = editor . getSelectionRange ( ) ; if ( currentRange . collapsed || ( editor . getElementAtCursor ( 'LI' , currentRange . startContainer ) == parentLINode && editor . getElementAtCursor ( 'LI' , currentRange . endContainer ) == parentLINode ) ) { relativeSelectionPath = roosterjs_editor_dom_1 . getSelectionPath ( parentLINode , currentRange ) ; clonedNode = parentLINode . cloneNode ( true ) ; } } workaroundForChrome ( editor ) ; } var existingList = editor . getElementAtCursor ( 'OL,UL' ) ; editor . getDocument ( ) . execCommand ( command , false , null ) ; var newParentNode ; editor . queryElements ( '.' + TEMP_NODE_CLASS , function ( node ) { newParentNode = node . parentNode ; editor . deleteNode ( node ) ; } ) ; var newList = editor . getElementAtCursor ( 'OL,UL' ) ; if ( newList == existingList ) { newList = null ; } if ( newList && clonedNode && newParentNode ) { if ( ( clonedNode instanceof HTMLElement ) ) { if ( newParentNode instanceof HTMLElement && clonedNode . tagName == newParentNode . tagName ) { newList . replaceChild ( clonedNode , newParentNode ) ; } if ( relativeSelectionPath && document . body . contains ( clonedNode ) ) { var newRange = roosterjs_editor_dom_1 . getRangeFromSelectionPath ( clonedNode , relativeSelectionPath ) ; editor . select ( newRange ) ; } } } return newList ; }
Browsers don't handle bullet/numbering list well, especially the formats when switching list statue
 So we workaround it by always adding format to list element
Browsers don ' t handle bullet / numbering list well especially the formats when switching list statue So we workaround it by always adding format to list element
/* Outdent */ // Chrome has some bad behavior when outdenting // in order to work around this, we need to take steps to deep clone the current node // after the outdent, we'll replace the new LI with the cloned content. // if the clonedNode and the newLIParent share the same tag name // we can 1:1 swap them // The alternative case is harder to solve, but we didn't specifically handle this before either.