How to use the roosterjs-editor-dom.unwrap function in roosterjs-editor-dom

To help you get started, we’ve selected a few roosterjs-editor-dom 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-api / lib / format / clearBlockFormat.ts View on Github external
let allChildrenAreBlock = ([].slice.call(node.childNodes) as Node[])
        .map(n => clearNodeFormat(n, tagsToUnwrap, tagsToStopUnwrap, attributesToPreserve))
        .reduce((previousValue, value) => previousValue && value, true);

    if (!canCollapse(tagsToStopUnwrap, node)) {
        return false;
    }

    let returnBlockElement = isBlockElement(node);

    // 2. If we should unwrap this tag, put it into an array and unwrap it later
    if (tagsToUnwrap.indexOf(getTagOfNode(node)) >= 0 || allChildrenAreBlock) {
        if (returnBlockElement && !allChildrenAreBlock) {
            wrap(node);
        }
        unwrap(node);
    } else {
        // 3. Otherwise, remove all attributes
        clearAttribute(node as HTMLElement, attributesToPreserve);
    }

    return returnBlockElement;
}
github microsoft / roosterjs / packages / roosterjs-editor-api / lib / format / toggleCodeBlock.ts View on Github external
function unwrapFunction(node: HTMLElement): Node {
    if (!node) {
        return null;
    }

    let firstChild = node.childNodes[0];
    if (node.childNodes.length == 1 && getTagOfNode(firstChild) == CODE_NODE_TAG) {
        unwrap(firstChild);
    }

    return unwrap(node);
}
github microsoft / roosterjs / packages / roosterjs-editor-plugins / lib / ContentEdit / features / quoteFeatures.ts View on Github external
editor.addUndoSnapshot(() => {
        let childOfQuote = cacheGetQuoteChild(event, editor);
        let parent: Node;
        if (getTagOfNode(childOfQuote) == QUOTE_TAG) {
            childOfQuote = wrap([].slice.call(childOfQuote.childNodes));
        }
        parent = splitBalancedNodeRange(childOfQuote);
        unwrap(parent);
        editor.select(childOfQuote, PositionType.Begin);
    });
    event.rawEvent.preventDefault();
github microsoft / roosterjs / packages / roosterjs-editor-plugins / lib / Paste / officeOnlineConverter / convertPastedContentFromWordOnline.ts View on Github external
collapsedListItemSections.forEach((section) => {
        if (getTagOfNode(section.firstChild) == 'DIV') {
            unwrap(section)
        }
    })
}
github microsoft / roosterjs / packages / roosterjs-editor-api / lib / format / toggleCodeBlock.ts View on Github external
function unwrapFunction(node: HTMLElement): Node {
    if (!node) {
        return null;
    }

    let firstChild = node.childNodes[0];
    if (node.childNodes.length == 1 && getTagOfNode(firstChild) == CODE_NODE_TAG) {
        unwrap(firstChild);
    }

    return unwrap(node);
}