Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
}
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);
}
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();
collapsedListItemSections.forEach((section) => {
if (getTagOfNode(section.firstChild) == 'DIV') {
unwrap(section)
}
})
}
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);
}