RichText/Archived/Rooster/Rooster.gcomp/Support/node_modules/roosterjs/dist/rooster-amd.js
/**
 * Clear the format in current selection, after cleaning, the format will be
 * changed to default format. The format that get cleaned include B/I/U/font name/
 * font size/text color/background color/align left/align right/align center/superscript/subscript
 * @param editor The editor instance
 */
Clear the format in current selection, after cleaning, the format will be
changed to default format.
Clear the format in current selection after cleaning the format will be changed to default format .
function clearFormat(editor) {
    editor.focus();
    editor.addUndoSnapshot(function () {
        execCommand_1.default(editor, "removeFormat" );
        editor.queryElements('[class]', 1 , function (node) {
            return node.removeAttribute('class');
        });
        var defaultFormat = editor.getDefaultFormat();
        var isDefaultFormatEmpty = Object.keys(defaultFormat).length === 0;
        editor.queryElements('[style]', 2 , function (node) {
            STYLES_TO_REMOVE.forEach(function (style) { return node.style.removeProperty(style); });
            if (isDefaultFormatEmpty && node.getAttribute('style') === '') {
                node.removeAttribute('style');
            }
        });
        if (!isDefaultFormatEmpty) {
            if (defaultFormat.fontFamily) {
                setFontName_1.default(editor, defaultFormat.fontFamily);
            }
            if (defaultFormat.fontSize) {
                setFontSize_1.default(editor, defaultFormat.fontSize);
            }
            if (defaultFormat.textColor) {
                if (defaultFormat.textColors) {
                    setTextColor_1.default(editor, defaultFormat.textColors);
                }
                else {
                    setTextColor_1.default(editor, defaultFormat.textColor);
                }
            }
            if (defaultFormat.backgroundColor) {
                if (defaultFormat.backgroundColors) {
                    setBackgroundColor_1.default(editor, defaultFormat.backgroundColors);
                }
                else {
                    setBackgroundColor_1.default(editor, defaultFormat.backgroundColor);
                }
            }
            if (defaultFormat.bold) {
                toggleBold_1.default(editor);
            }
            if (defaultFormat.italic) {
                toggleItalic_1.default(editor);
            }
            if (defaultFormat.underline) {
                toggleUnderline_1.default(editor);
            }
        }
    }, "Format" );
}
function clearFormat ( editor ) { editor . focus ( ) ; editor . addUndoSnapshot ( function ( ) { execCommand_1 . default ( editor , "removeFormat" ) ; editor . queryElements ( '[class]' , 1 , function ( node ) { return node . removeAttribute ( 'class' ) ; } ) ; var defaultFormat = editor . getDefaultFormat ( ) ; var isDefaultFormatEmpty = Object . keys ( defaultFormat ) . length === 0 ; editor . queryElements ( '[style]' , 2 , function ( node ) { STYLES_TO_REMOVE . forEach ( function ( style ) { return node . style . removeProperty ( style ) ; } ) ; if ( isDefaultFormatEmpty && node . getAttribute ( 'style' ) === '' ) { node . removeAttribute ( 'style' ) ; } } ) ; if ( ! isDefaultFormatEmpty ) { if ( defaultFormat . fontFamily ) { setFontName_1 . default ( editor , defaultFormat . fontFamily ) ; } if ( defaultFormat . fontSize ) { setFontSize_1 . default ( editor , defaultFormat . fontSize ) ; } if ( defaultFormat . textColor ) { if ( defaultFormat . textColors ) { setTextColor_1 . default ( editor , defaultFormat . textColors ) ; } else { setTextColor_1 . default ( editor , defaultFormat . textColor ) ; } } if ( defaultFormat . backgroundColor ) { if ( defaultFormat . backgroundColors ) { setBackgroundColor_1 . default ( editor , defaultFormat . backgroundColors ) ; } else { setBackgroundColor_1 . default ( editor , defaultFormat . backgroundColor ) ; } } if ( defaultFormat . bold ) { toggleBold_1 . default ( editor ) ; } if ( defaultFormat . italic ) { toggleItalic_1 . default ( editor ) ; } if ( defaultFormat . underline ) { toggleUnderline_1 . default ( editor ) ; } } } , "Format" ) ; }
Clear the format in current selection, after cleaning, the format will be
 changed to default format.
Clear the format in current selection after cleaning the format will be changed to default format .
/* RemoveFormat */ /* OnSelection */ /* InSelection */ // when default format is empty, keep the HTML minimum by removing style attribute if there's no style // (note: because default format is empty, we're not adding style back in) /* Format */