mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
parent
94c4f99343
commit
82f1cda09a
2 changed files with 14 additions and 2 deletions
7
ts/lib/shadow-dom.d.ts
vendored
Normal file
7
ts/lib/shadow-dom.d.ts
vendored
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
export {};
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface DocumentOrShadowRoot {
|
||||||
|
getSelection(): Selection | null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -80,9 +80,14 @@ function setInnerHTML(element: Element, html: string): void {
|
||||||
|
|
||||||
const renderError =
|
const renderError =
|
||||||
(type: string) =>
|
(type: string) =>
|
||||||
(error: Error): string => {
|
(error: unknown): string => {
|
||||||
const errorMessage = String(error).substring(0, 2000);
|
const errorMessage = String(error).substring(0, 2000);
|
||||||
const errorStack = String(error.stack).substring(0, 2000);
|
let errorStack: string;
|
||||||
|
if (error instanceof Error) {
|
||||||
|
errorStack = String(error.stack).substring(0, 2000);
|
||||||
|
} else {
|
||||||
|
errorStack = "";
|
||||||
|
}
|
||||||
return `<div>Invalid ${type} on card: ${errorMessage}\n${errorStack}</div>`.replace(
|
return `<div>Invalid ${type} on card: ${errorMessage}\n${errorStack}</div>`.replace(
|
||||||
/\n/g,
|
/\n/g,
|
||||||
"<br>"
|
"<br>"
|
||||||
|
|
Loading…
Reference in a new issue