How to use the roosterjs-html-sanitizer.HtmlSanitizer function in roosterjs-html-sanitizer

To help you get started, we’ve selected a few roosterjs-html-sanitizer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / roosterjs / packages / roosterjs-editor-plugins / lib / Paste / wacConverter / convertPastedContentFromWac.ts View on Github external
// the list exist before the itertor element. Then insert the list element before
            // iterator
            listContainerParent.insertBefore(convertedListElement, currentListContainer);
        } else {
            // If the iterator doesn't exist, it means that the list element is the last element
            // of the parent, so simply append list element into the parent.
            listContainerParent.appendChild(convertedListElement);
        }

        // After previous code finish executing,
        listContainerElement = wrapperElement.getElementsByClassName(LIST_CONTAINER_ELEMENT_CLASS_NAME)[0];
    }

    doc.body.innerHTML = wrapperElement.innerHTML

    let sanitizer = new HtmlSanitizer({
        elementCallbacks: {
            ['O:P']: () => false,
        },
        additionalAllowAttributes: ['class'],
    });
    sanitizer.sanitize(doc.body);
}
github microsoft / roosterjs / packages / roosterjs-editor-plugins / lib / Paste / wordConverter / convertPastedContentFromWord.ts View on Github external
export default function convertPastedContentFromWord(doc: HTMLDocument) {
    let sanitizer = new HtmlSanitizer({
        elementCallbacks: {
            ['O:P']: element => element.innerHTML == ' ', // Preserve  when its innerHTML is " " to avoid dropping an empty line
        },
        additionalAllowAttributes: ['class'],
    });
    sanitizer.sanitize(doc.body);

    let wordConverter = createWordConverter();

    // First find all the nodes that we need to check for list item information
    // This call will return all the p and header elements under the root node.. These are the elements that
    // Word uses a list items, so we'll only process them and avoid walking the whole tree.
    let elements = doc.querySelectorAll('p');
    if (elements.length > 0) {
        wordConverter.wordConverterArgs = createWordConverterArguments(elements);
        if (processNodesDiscovery(wordConverter)) {
github microsoft / roosterjs / packages / roosterjs-editor-plugins / lib / Paste / excelConverter / convertPastedContentFromExcel.ts View on Github external
export default function convertPastedContentFromExcel(doc: HTMLDocument) {
    let sanitizer = new HtmlSanitizer({
        styleCallbacks: {
            border: (value, element) => value != 'none' || element.style.border != 'none',
        },
        additionalAllowAttributes: ['class'],
    });
    sanitizer.sanitize(doc.body);

    let styleNode = doc.createElement('style');
    doc.body.appendChild(styleNode);
    styleNode.innerHTML = 'td {border: solid 1px #d4d4d4}';
    sanitizer.convertGlobalCssToInlineCss(doc);
}

roosterjs-html-sanitizer

This package is deprecated, and this is the last version of this package.

MIT
Latest version published 4 years ago

Package Health Score

61 / 100
Full package analysis

Similar packages