| 1 |
// Copyright (c) Jupyter Development Team. |
| 2 |
// Distributed under the terms of the Modified BSD License. |
| 3 |
export { uuid, resolvePromisesDict } from '@jupyter-widgets/base'; |
| 4 |
/** |
| 5 |
* Apply MathJax rendering to an element, and optionally set its text. |
| 6 |
* |
| 7 |
* If MathJax is not available, make no changes. |
| 8 |
* |
| 9 |
* Parameters |
| 10 |
* ---------- |
| 11 |
* element: Node |
| 12 |
* text: optional string |
| 13 |
*/ |
| 14 |
export function typeset(element, text) { |
| 15 |
if (text !== void 0) { |
| 16 |
element.textContent = text; |
| 17 |
} |
| 18 |
if (window.MathJax !== void 0) { |
| 19 |
MathJax.Hub.Queue(['Typeset', MathJax.Hub, element]); |
| 20 |
} |
| 21 |
} |
| 22 |
/** |
| 23 |
* escape text to HTML |
| 24 |
*/ |
| 25 |
export function escape_html(text) { |
| 26 |
const esc = document.createElement('div'); |
| 27 |
esc.textContent = text; |
| 28 |
return esc.innerHTML; |
| 29 |
} |
| 30 |
/** |
| 31 |
* Creates a wrappable Promise rejection function. |
| 32 |
*/ |
| 33 |
export function reject(message, log) { |
| 34 |
return function promiseRejection(error) { |
| 35 |
if (log) { |
| 36 |
console.error(new Error(message)); |
| 37 |
} |
| 38 |
throw error; |
| 39 |
}; |
| 40 |
} |
| 41 |
//# sourceMappingURL=utils.js.map |