How to use the roosterjs-html-sanitizer.splitWithFragment 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 / fragmentHandler.ts View on Github external
export default function fragmentHandler(doc: HTMLDocument, source: string) {
    let [html, before] = splitWithFragment(source);
    let firstNode = doc && doc.body && (doc.querySelector('html') as HTMLElement);
    if (getTagOfNode(firstNode) == 'HTML') {
        if (firstNode.getAttribute(WORD_ATTRIBUTE_NAME) == WORD_ATTRIBUTE_VALUE) {
            // Handle HTML copied from MS Word
            doc.body.innerHTML = html;
            convertPastedContentFromWord(doc);
        } else if (isWAC(firstNode)) {
            // The WAC converter only supports word for now.
            convertPastedContentFromWac(doc);
        } else if (firstNode.getAttribute(EXCEL_ATTRIBUTE_NAME) == EXCEL_ATTRIBUTE_VALUE) {
            // Handle HTML copied from MS Excel
            if (html.match(LAST_TD_END_REGEX)) {
                let trMatch = before.match(LAST_TR_REGEX);
                let tr = trMatch ? trMatch[0] : '';
                html = tr + html + '';
            }

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