mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 14:39:34 +01:00
17 lines
485 B
JavaScript
17 lines
485 B
JavaScript
import { parse } from "node-html-parser";
|
|
import { decodeHTML5 } from "entities";
|
|
|
|
export const parseHTML =
|
|
typeof DOMParser === "undefined"
|
|
? (input) => parse(input)
|
|
: (input) => new DOMParser().parseFromString(input, "text/html");
|
|
|
|
export function getDummyDocument() {
|
|
const doc = parseHTML("<div></div>");
|
|
return typeof DOMParser === "undefined" ? doc : doc;
|
|
}
|
|
|
|
export function getInnerText(element) {
|
|
return decodeHTML5(element.innerText || element.textContent);
|
|
}
|