Fix lit files, reallow html alerts

This commit is contained in:
Snarling 2022-09-11 15:20:25 -04:00
parent 88e2cdf09c
commit dc59a10e19
3 changed files with 13 additions and 4 deletions

@ -1,3 +1,4 @@
import React from "react";
import { Literatures } from "./Literatures"; import { Literatures } from "./Literatures";
import { dialogBoxCreate } from "../ui/React/DialogBox"; import { dialogBoxCreate } from "../ui/React/DialogBox";
@ -7,5 +8,5 @@ export function showLiterature(fn: string): void {
return; return;
} }
const txt = `<i>${litObj.title}</i><br><br>${litObj.txt}`; const txt = `<i>${litObj.title}</i><br><br>${litObj.txt}`;
dialogBoxCreate(txt); dialogBoxCreate(txt, true);
} }

@ -1778,7 +1778,7 @@ const base: InternalAPI<NS> = {
(ctx: NetscriptContext) => (ctx: NetscriptContext) =>
(_message: unknown): void => { (_message: unknown): void => {
const message = helpers.string(ctx, "message", _message); const message = helpers.string(ctx, "message", _message);
dialogBoxCreate(message); dialogBoxCreate(message, true);
}, },
toast: toast:
(ctx: NetscriptContext) => (ctx: NetscriptContext) =>

@ -3,6 +3,14 @@ import { AlertEvents } from "./AlertManager";
import React from "react"; import React from "react";
import { Typography } from "@mui/material"; import { Typography } from "@mui/material";
export function dialogBoxCreate(txt: string | JSX.Element): void { export function dialogBoxCreate(txt: string | JSX.Element, html = false): void {
AlertEvents.emit(typeof txt === "string" ? <Typography component="span">{txt}</Typography> : txt); AlertEvents.emit(
typeof txt !== "string" ? (
txt
) : html ? (
<div dangerouslySetInnerHTML={{ __html: txt }}></div>
) : (
<Typography component="span">{txt}</Typography>
),
);
} }