Fix links, header and export text

This commit is contained in:
Jaiwanth 2021-08-18 08:37:10 +05:30
parent 4dae737922
commit 7bad0b99d1
3 changed files with 36 additions and 17 deletions

View File

@ -443,16 +443,18 @@ export default class EventTile extends React.Component<IProps, IState> {
componentDidMount() {
this.suppressReadReceiptAnimation = false;
const client = this.context;
client.on("deviceVerificationChanged", this.onDeviceVerificationChanged);
client.on("userTrustStatusChanged", this.onUserVerificationChanged);
this.props.mxEvent.on("Event.decrypted", this.onDecrypted);
if (this.props.showReactions) {
this.props.mxEvent.on("Event.relationsCreated", this.onReactionsCreated);
}
if (!this.props.forExport) {
client.on("deviceVerificationChanged", this.onDeviceVerificationChanged);
client.on("userTrustStatusChanged", this.onUserVerificationChanged);
this.props.mxEvent.on("Event.decrypted", this.onDecrypted);
if (this.props.showReactions) {
this.props.mxEvent.on("Event.relationsCreated", this.onReactionsCreated);
}
if (this.shouldShowSentReceipt || this.shouldShowSendingReceipt) {
client.on("Room.receipt", this.onRoomReceipt);
this.isListeningForReceipts = true;
if (this.shouldShowSentReceipt || this.shouldShowSendingReceipt) {
client.on("Room.receipt", this.onRoomReceipt);
this.isListeningForReceipts = true;
}
}
}

View File

@ -15,17 +15,18 @@ limitations under the License.
*/
import React from "react";
import ReactDOM from "react-dom";
import Exporter from "./Exporter";
import { mediaFromMxc } from "../../customisations/Media";
import { Room } from "matrix-js-sdk/src/models/room";
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
import { renderToStaticMarkup } from "react-dom/server";
import { renderToStaticMarkup, renderToString } from "react-dom/server";
import { Layout } from "../../settings/Layout";
import { shouldFormContinuation } from "../../components/structures/MessagePanel";
import { formatFullDateNoDayNoTime, wantsDateSeparator } from "../../DateUtils";
import { RoomPermalinkCreator } from "../permalinks/Permalinks";
import { _t } from "../../languageHandler";
import { EventType } from "matrix-js-sdk/src/@types/event";
import { EventType, MsgType } from "matrix-js-sdk/src/@types/event";
import * as Avatar from "../../Avatar";
import EventTile, { haveTileForEvent } from "../../components/views/rooms/EventTile";
import DateSeparator from "../../components/views/messages/DateSeparator";
@ -115,7 +116,7 @@ export default class HTMLExporter extends Exporter {
{ exporterName ? (
<>
<b>{ exporterName }</b>
{ exporter }
{ " (" + exporter + ")" }
</>
) : (
<b>{ exporter }</b>
@ -263,6 +264,7 @@ export default class HTMLExporter extends Exporter {
replacingEventId={mxEv.replacingEventId()}
forExport={true}
readReceipts={null}
alwaysShowTimestamps={true}
readReceiptMap={null}
showUrlPreview={false}
checkUnmounting={() => false}
@ -285,10 +287,26 @@ export default class HTMLExporter extends Exporter {
protected async getEventTileMarkup(mxEv: MatrixEvent, continuation: boolean, filePath?: string) {
const hasAvatar = !!this.getAvatarURL(mxEv);
if (hasAvatar) await this.saveAvatarIfNeeded(mxEv);
const EventTile = this.getEventTile(mxEv, continuation);
let eventTileMarkup: string;
const eventTile = this.getEventTile(mxEv, continuation);
if (
mxEv.getContent().msgtype == MsgType.Emote ||
mxEv.getContent().msgtype == MsgType.Notice ||
mxEv.getContent().msgtype === MsgType.Text
) {
// to linkify textual events, we'll need lifecycle methods which won't be invoked in renderToString
// So, we'll have to render the component into a temporary root element
const tempRoot = document.createElement('div');
ReactDOM.render(
EventTile,
tempRoot,
);
eventTileMarkup = tempRoot.innerHTML;
} else {
eventTileMarkup = renderToString(EventTile);
}
let eventTileMarkup = renderToStaticMarkup(eventTile);
if (filePath) {
const mxc = mxEv.getContent().url || mxEv.getContent().file?.url;
eventTileMarkup = eventTileMarkup.split(mxc).join(filePath);
@ -390,8 +408,7 @@ export default class HTMLExporter extends Exporter {
}
public async export() {
this.updateProgress("Starting export process", true, false);
this.updateProgress("Fetching events");
this.updateProgress("Starting export...");
const fetchStart = performance.now();
const res = await this.getRequiredEvents();

View File

@ -121,7 +121,7 @@ const getExportCSS = async (): Promise<string> => {
}
.mx_ReplyThread_Export {
margin-top: -5px;
margin-top: 0px;
margin-bottom: 5px;
}