diff --git a/res/css/structures/_ViewSource.scss b/res/css/structures/_ViewSource.scss index e3d6135ef3..f1ada65786 100644 --- a/res/css/structures/_ViewSource.scss +++ b/res/css/structures/_ViewSource.scss @@ -34,8 +34,13 @@ limitations under the License. padding: 0.5em 1em 0.5em 1em; word-wrap: break-word; white-space: pre-wrap; + overflow-wrap: anywhere; } .mx_ViewSource_details { margin-top: 0.8em; } + +.mx_ViewSource_container { + max-width: calc(100% - 24px); +} diff --git a/src/components/structures/ViewSource.tsx b/src/components/structures/ViewSource.tsx index 477dd4ca9a..e84a26409e 100644 --- a/src/components/structures/ViewSource.tsx +++ b/src/components/structures/ViewSource.tsx @@ -29,6 +29,7 @@ import BaseDialog from "../views/dialogs/BaseDialog"; import { DevtoolsContext } from "../views/dialogs/devtools/BaseTool"; import { StateEventEditor } from "../views/dialogs/devtools/RoomState"; import { stringify, TimelineEventEditor } from "../views/dialogs/devtools/Event"; +import CopyableText from "../views/elements/CopyableText"; interface IProps extends IDialogProps { mxEvent: MatrixEvent; // the MatrixEvent associated with the context menu @@ -63,29 +64,58 @@ export default class ViewSource extends React.Component { // @ts-ignore const decryptedEventSource = mxEvent.clearEvent; // FIXME: clearEvent is private const originalEventSource = mxEvent.event; - + const copyOriginalFunc = (): string => { + return stringify(originalEventSource); + }; if (isEncrypted) { + const copyDecryptedFunc = (): string => { + return stringify(decryptedEventSource); + }; return ( <>
- { _t("Decrypted event source") } + + { _t("Decrypted event source") } + - { stringify(decryptedEventSource) } +
+ + + { stringify(decryptedEventSource) } + + +
- { _t("Original event source") } + + { _t("Original event source") } + - { stringify(originalEventSource) } +
+ + + { stringify(originalEventSource) } + + +
); } else { return ( <> -
{ _t("Original event source") }
- { stringify(originalEventSource) } +
+ { _t("Original event source") } +
+
+ + + { stringify(originalEventSource) } + + +
); }