mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-18 14:44:58 +08:00
Fix links, header and export text
This commit is contained in:
parent
4dae737922
commit
7bad0b99d1
@ -443,16 +443,18 @@ export default class EventTile extends React.Component<IProps, IState> {
|
|||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.suppressReadReceiptAnimation = false;
|
this.suppressReadReceiptAnimation = false;
|
||||||
const client = this.context;
|
const client = this.context;
|
||||||
client.on("deviceVerificationChanged", this.onDeviceVerificationChanged);
|
if (!this.props.forExport) {
|
||||||
client.on("userTrustStatusChanged", this.onUserVerificationChanged);
|
client.on("deviceVerificationChanged", this.onDeviceVerificationChanged);
|
||||||
this.props.mxEvent.on("Event.decrypted", this.onDecrypted);
|
client.on("userTrustStatusChanged", this.onUserVerificationChanged);
|
||||||
if (this.props.showReactions) {
|
this.props.mxEvent.on("Event.decrypted", this.onDecrypted);
|
||||||
this.props.mxEvent.on("Event.relationsCreated", this.onReactionsCreated);
|
if (this.props.showReactions) {
|
||||||
}
|
this.props.mxEvent.on("Event.relationsCreated", this.onReactionsCreated);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.shouldShowSentReceipt || this.shouldShowSendingReceipt) {
|
if (this.shouldShowSentReceipt || this.shouldShowSendingReceipt) {
|
||||||
client.on("Room.receipt", this.onRoomReceipt);
|
client.on("Room.receipt", this.onRoomReceipt);
|
||||||
this.isListeningForReceipts = true;
|
this.isListeningForReceipts = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,17 +15,18 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import ReactDOM from "react-dom";
|
||||||
import Exporter from "./Exporter";
|
import Exporter from "./Exporter";
|
||||||
import { mediaFromMxc } from "../../customisations/Media";
|
import { mediaFromMxc } from "../../customisations/Media";
|
||||||
import { Room } from "matrix-js-sdk/src/models/room";
|
import { Room } from "matrix-js-sdk/src/models/room";
|
||||||
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
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 { Layout } from "../../settings/Layout";
|
||||||
import { shouldFormContinuation } from "../../components/structures/MessagePanel";
|
import { shouldFormContinuation } from "../../components/structures/MessagePanel";
|
||||||
import { formatFullDateNoDayNoTime, wantsDateSeparator } from "../../DateUtils";
|
import { formatFullDateNoDayNoTime, wantsDateSeparator } from "../../DateUtils";
|
||||||
import { RoomPermalinkCreator } from "../permalinks/Permalinks";
|
import { RoomPermalinkCreator } from "../permalinks/Permalinks";
|
||||||
import { _t } from "../../languageHandler";
|
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 * as Avatar from "../../Avatar";
|
||||||
import EventTile, { haveTileForEvent } from "../../components/views/rooms/EventTile";
|
import EventTile, { haveTileForEvent } from "../../components/views/rooms/EventTile";
|
||||||
import DateSeparator from "../../components/views/messages/DateSeparator";
|
import DateSeparator from "../../components/views/messages/DateSeparator";
|
||||||
@ -115,7 +116,7 @@ export default class HTMLExporter extends Exporter {
|
|||||||
{ exporterName ? (
|
{ exporterName ? (
|
||||||
<>
|
<>
|
||||||
<b>{ exporterName }</b>
|
<b>{ exporterName }</b>
|
||||||
{ exporter }
|
{ " (" + exporter + ")" }
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<b>{ exporter }</b>
|
<b>{ exporter }</b>
|
||||||
@ -263,6 +264,7 @@ export default class HTMLExporter extends Exporter {
|
|||||||
replacingEventId={mxEv.replacingEventId()}
|
replacingEventId={mxEv.replacingEventId()}
|
||||||
forExport={true}
|
forExport={true}
|
||||||
readReceipts={null}
|
readReceipts={null}
|
||||||
|
alwaysShowTimestamps={true}
|
||||||
readReceiptMap={null}
|
readReceiptMap={null}
|
||||||
showUrlPreview={false}
|
showUrlPreview={false}
|
||||||
checkUnmounting={() => false}
|
checkUnmounting={() => false}
|
||||||
@ -285,10 +287,26 @@ export default class HTMLExporter extends Exporter {
|
|||||||
protected async getEventTileMarkup(mxEv: MatrixEvent, continuation: boolean, filePath?: string) {
|
protected async getEventTileMarkup(mxEv: MatrixEvent, continuation: boolean, filePath?: string) {
|
||||||
const hasAvatar = !!this.getAvatarURL(mxEv);
|
const hasAvatar = !!this.getAvatarURL(mxEv);
|
||||||
if (hasAvatar) await this.saveAvatarIfNeeded(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) {
|
if (filePath) {
|
||||||
const mxc = mxEv.getContent().url || mxEv.getContent().file?.url;
|
const mxc = mxEv.getContent().url || mxEv.getContent().file?.url;
|
||||||
eventTileMarkup = eventTileMarkup.split(mxc).join(filePath);
|
eventTileMarkup = eventTileMarkup.split(mxc).join(filePath);
|
||||||
@ -390,8 +408,7 @@ export default class HTMLExporter extends Exporter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async export() {
|
public async export() {
|
||||||
this.updateProgress("Starting export process", true, false);
|
this.updateProgress("Starting export...");
|
||||||
this.updateProgress("Fetching events");
|
|
||||||
|
|
||||||
const fetchStart = performance.now();
|
const fetchStart = performance.now();
|
||||||
const res = await this.getRequiredEvents();
|
const res = await this.getRequiredEvents();
|
||||||
|
@ -121,7 +121,7 @@ const getExportCSS = async (): Promise<string> => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.mx_ReplyThread_Export {
|
.mx_ReplyThread_Export {
|
||||||
margin-top: -5px;
|
margin-top: 0px;
|
||||||
margin-bottom: 5px;
|
margin-bottom: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user