mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 14:39:34 +01:00
20 lines
501 B
JavaScript
20 lines
501 B
JavaScript
import { decodeHTML5 } from "entities";
|
|
import { Window } from "happy-dom";
|
|
|
|
const RealDOMParser =
|
|
"window" in global && "DOMParser" in window
|
|
? new window.DOMParser()
|
|
: new new Window().DOMParser();
|
|
|
|
export const parseHTML = (input) =>
|
|
RealDOMParser.parseFromString(input, "text/html");
|
|
|
|
export function getDummyDocument() {
|
|
const doc = parseHTML("<div></div>");
|
|
return doc;
|
|
}
|
|
|
|
export function getInnerText(element) {
|
|
return decodeHTML5(element.innerText || element.textContent);
|
|
}
|