Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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);
}
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)) {
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);
}