Status: strip compatibility features from markup when importing

This commit is contained in:
Alex Gleason
2022-01-24 20:39:22 -06:00
parent 35ab65efcf
commit 462df83989
4 changed files with 23 additions and 22 deletions

View File

@@ -4,3 +4,23 @@ export const unescapeHTML = (html) => {
wrapper.innerHTML = html.replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n').replace(/<[^>]*>/g, '');
return wrapper.textContent;
};
export const stripCompatibilityFeatures = html => {
const node = document.createElement('div');
node.innerHTML = html;
const selectors = [
'.quote-inline',
'.recipients-inline',
];
selectors.forEach(selector => {
const elem = node.querySelector(selector);
if (elem) {
elem.remove();
}
});
return node.innerHTML;
};