From 334b7ef04a193cb664928e78321fcd12d29e4925 Mon Sep 17 00:00:00 2001 From: Jaiwanth Date: Wed, 26 May 2021 18:00:27 +0530 Subject: [PATCH] Implement animated scroll to base event for replies --- src/utils/exportUtils/HtmlExport.ts | 29 ++++++++++++++++++++++----- src/utils/exportUtils/StreamToZip.ts | 30 ++++++++++++++-------------- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/src/utils/exportUtils/HtmlExport.ts b/src/utils/exportUtils/HtmlExport.ts index 8e6070cff6..1e3984e34e 100644 --- a/src/utils/exportUtils/HtmlExport.ts +++ b/src/utils/exportUtils/HtmlExport.ts @@ -39,7 +39,7 @@ body { } .mx_page_wrap a { - color: #168acd; + color: #238CF5; text-decoration: none; } @@ -126,11 +126,11 @@ a.mx_block_link:hover { .mx_message { margin: 0 -10px; - transition: background-color 2.0s ease; + transition: background-color 1.3s ease; } div.mx_selected { - background-color: rgba(242,246,250,255); + background-color: #eeeeee; transition: background-color 0.5s ease; } @@ -276,6 +276,20 @@ div.mx_selected { } `; +const js = ` +function scrollToElement(replyId){ + let el = document.getElementById(replyId); + el.scrollIntoViewIfNeeded({ + behaviour: "smooth", + block: "start", + }); + el.classList.add("mx_selected"); + setTimeout(() => { + el.classList.remove("mx_selected"); + }, 1000); +} +` + export default class HTMLExporter extends Exporter { protected zip: JSZip; protected avatars: Map; @@ -295,6 +309,7 @@ export default class HTMLExporter extends Exporter { Exported Data +
@@ -459,6 +474,10 @@ export default class HTMLExporter extends Exporter { break; } + if (isReply) { + messageBody = event.getContent().formatted_body.replace(/.*<\/mx-reply>/, '') + } + return `
${!joined ? userPic : ``} @@ -472,7 +491,7 @@ export default class HTMLExporter extends Exporter {
`: ``} ${isReply ? `
- In reply to this message + In reply to this message
`: ``} ${messageBody}
@@ -515,7 +534,7 @@ export default class HTMLExporter extends Exporter { this.zip.file("index.html", html); this.zip.file("css/style.css", css); - + this.zip.file("js/script.js", js); const filename = `matrix-export-${new Date().toISOString()}.zip`; //Generate the zip file asynchronously diff --git a/src/utils/exportUtils/StreamToZip.ts b/src/utils/exportUtils/StreamToZip.ts index 769fa91dba..01a2880386 100644 --- a/src/utils/exportUtils/StreamToZip.ts +++ b/src/utils/exportUtils/StreamToZip.ts @@ -1,17 +1,17 @@ /*Not to be reviewed now*/ -class fileCheckSum { - protected CRC32: number; - public table: any[]; - constructor() { - this.CRC32 = -1 - } +// class fileCheckSum { +// protected CRC32: number; +// public table: any[]; +// constructor() { +// this.CRC32 = -1 +// } - protected append(data: any[]) { - let crc = this.CRC32 | 0; - const table = this.table; - for (let offset = 0, len = data.length | 0; offset < len; offset++) { - crc = (crc >>> 8) ^ table[(crc ^ data[offset]) & 0xFF] - } - this.CRC32 = crc - } -} +// protected append(data: any[]) { +// let crc = this.CRC32 | 0; +// const table = this.table; +// for (let offset = 0, len = data.length | 0; offset < len; offset++) { +// crc = (crc >>> 8) ^ table[(crc ^ data[offset]) & 0xFF] +// } +// this.CRC32 = crc +// } +// }