Skip to content
Snippets Groups Projects
Commit 4057573a authored by Igor Markin's avatar Igor Markin
Browse files

Cover all chrome/edge/safari cases

parent 300e62d9
No related branches found
No related tags found
1 merge request!1Initial
...@@ -18,7 +18,7 @@ const getTestCasesDirs = (testCasesPath: string) => { ...@@ -18,7 +18,7 @@ const getTestCasesDirs = (testCasesPath: string) => {
return fs.statSync(testCasesPath + "/" + file).isDirectory(); return fs.statSync(testCasesPath + "/" + file).isDirectory();
}); });
}; };
console.debug = () => {}
const getNormalizedHtml = ( const getNormalizedHtml = (
testCasePath: string testCasePath: string
): { ): {
...@@ -61,7 +61,7 @@ describe("Outlook emails HTML normalization", () => { ...@@ -61,7 +61,7 @@ describe("Outlook emails HTML normalization", () => {
try { try {
normalizedHtmls = getNormalizedHtml(testCasePath); normalizedHtmls = getNormalizedHtml(testCasePath);
} catch (e) { } catch (e) {
console.log("Invalid test case: " + dirName); console.log(`Invalid test case: ${casesName}/${dirName}`);
return; return;
} }
...@@ -75,7 +75,9 @@ describe("Outlook emails HTML normalization", () => { ...@@ -75,7 +75,9 @@ describe("Outlook emails HTML normalization", () => {
describe("Emails Chrome", describeTestCases("chrome")); describe("Emails Chrome", describeTestCases("chrome"));
describe("Emails Edge", describeTestCases("edge")); describe("Emails Edge", describeTestCases("edge"));
//describe("Emails Gmail", describeTestCases("gmail")); describe("Emails Safari", describeTestCases("safari"));
// describe("Emails MacOS", describeTestCases("macos"));
// describe("Emails Windows", describeTestCases("windows"));
// it("Emails Edge", () => { // it("Emails Edge", () => {
// }) // })
......
const DUMMY_QR_CODE_ID = "dummyQrCode"; const DUMMY_QR_CODE_ID = "dummyQrCode";
export const ELEMENT_TYPES_TO_REMOVE = { br: true, hr: true }; export const ELEMENT_TYPES_TO_REMOVE = { br: true, hr: true, use: true, svg: true };
export const ATTRIBUTES_TO_KEEP = { export const ATTRIBUTES_TO_KEEP = {
alt: true, alt: true,
......
...@@ -32,11 +32,31 @@ export const amendOutlookNodes = (document: HTMLDocument): void => { ...@@ -32,11 +32,31 @@ export const amendOutlookNodes = (document: HTMLDocument): void => {
/** /**
* Remove quoted text * Remove quoted text
*/ */
const appendOnSendNode = document.querySelector(
// Quoted text in web apps
const appendOnSend = document.querySelector(
"[id*='appendonsend']" "[id*='appendonsend']"
) as Node; ) as Node;
if (appendOnSendNode) {
let child = appendOnSendNode; if (appendOnSend) {
let child = appendOnSend;
while (child) {
const nextSibling = child.nextSibling;
child.parentNode.removeChild(child);
child = nextSibling as Node;
}
}
// Quoted text in desktop apps
const mailOriginal = document.querySelector("[name*='_MailOriginal']") as Node;
if (mailOriginal) {
const separatorCandidate = mailOriginal.parentNode as Node;
// while (!(separatorCandidate.parentNode as Element).classList.contains("WordSection1")) {
// separatorCandidate = separatorCandidate.parentNode;
// }
let child = separatorCandidate;
while (child) { while (child) {
const nextSibling = child.nextSibling; const nextSibling = child.nextSibling;
child.parentNode.removeChild(child); child.parentNode.removeChild(child);
...@@ -47,20 +67,20 @@ export const amendOutlookNodes = (document: HTMLDocument): void => { ...@@ -47,20 +67,20 @@ export const amendOutlookNodes = (document: HTMLDocument): void => {
/** /**
* Get rid of attachments panes * Get rid of attachments panes
*/ */
const attachmentsPanesConatiner = document.getElementById( const attachmentsPanesContainer = document.getElementById(
"OwaReferenceAttachments" "OwaReferenceAttachments"
); );
const attachmentsPanesContainerEnd = document.getElementById( const attachmentsPanesContainerEnd = document.getElementById(
"OwaReferenceAttachmentsEnd" "OwaReferenceAttachmentsEnd"
); );
if (attachmentsPanesConatiner) { if (attachmentsPanesContainer) {
const as = attachmentsPanesConatiner.getElementsByTagName("a"); const as = attachmentsPanesContainer.getElementsByTagName("a");
Array.from(as).forEach((a) => { Array.from(as).forEach((a) => {
cloneAnchorFromPane(a, attachmentsPanesConatiner as HTMLElement); cloneAnchorFromPane(a, attachmentsPanesContainer as HTMLElement);
}); });
attachmentsPanesConatiner.parentNode.removeChild(attachmentsPanesConatiner); attachmentsPanesContainer.parentNode.removeChild(attachmentsPanesContainer);
} }
attachmentsPanesContainerEnd && attachmentsPanesContainerEnd &&
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment