Add flag to send HTML or plain Text to banner (#947)

This commit is contained in:
Fábio Rosado
2022-11-14 18:36:54 +00:00
committed by GitHub
parent adfa9a9b05
commit da2728e6df
4 changed files with 97 additions and 61 deletions

View File

@@ -41,8 +41,8 @@ export function ensureUniqueId(el: HTMLElement) {
if (el.id === '') el.id = `py-internal-${_uniqueIdCounter++}`;
}
export function showWarning(msg: string): void {
_createAlertBanner(msg, "warning")
export function showWarning(msg: string, messageType: "text" | "html" = "text"): void {
_createAlertBanner(msg, "warning", messageType);
}
export function handleFetchError(e: Error, singleFile: string) {
@@ -69,8 +69,8 @@ export function handleFetchError(e: Error, singleFile: string) {
// We need to create the banner because `handleFetchError` is called before we
// use withUserErrorHandler in main.js we are also disabling the log message
// because it will be logged by the uncaught exception in promise.
_createAlertBanner(errorContent, "error", false)
throw new UserError(errorContent)
_createAlertBanner(errorContent, "error", "html", false);
throw new UserError(errorContent);
}
export function readTextFromPath(path: string) {