Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var mswTest = pasteContent.replace(/(class=(")?Mso[a-zA-Z]+(")?)/g, "");
let wordPaste = false;
// the string to import as sanitized by hax
let newContent = "";
mswTest = mswTest.replace("mso-style-", "");
if (pasteContent != mswTest) {
wordPaste = true;
}
// clear empty span tags that can pop up
pasteContent = pasteContent.replace(/<span>\s*?<\/span>/g, " ");
// clean up div tags that can come in from contenteditable pastes
// p tags make more sense in the content area
pasteContent = pasteContent.replace(/<div>/g, "<p></p>");
// NOW we can safely handle paste from word cases
pasteContent = stripMSWord(pasteContent);
// edges that some things preserve empty white space needlessly
let haxElements = window.HaxStore.htmlToHaxElements(pasteContent);
// if interpretation as HTML fails then let's ignore this whole thing
// as we allow normal contenteditable to handle the paste
// we only worry about HTML structures
if (haxElements.length === 0) {
// wrap in a paragraph tag if there is any this ensures it correctly imports
// as it might not have evaluated above as having elements bc of the scrubber
if (wordPaste) {
newContent = pasteContent;
} else {
return false;
}
}
// account for incredibly basic pastes of single groups of characters
else if (haxElements.length === 1 && haxElements[0].tag === "p") {</div></span>