UNPKG

synapse-react-client

Version:

[![npm version](https://badge.fury.io/js/synapse-react-client.svg)](https://badge.fury.io/js/synapse-react-client) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettie

56 lines (55 loc) 1.7 kB
import { jsx as o, jsxs as l, Fragment as h } from "react/jsx-runtime"; import { useGetIsUserMemberOfTeam as p } from "../../../synapse-queries/team/useTeamMembers.js"; import { sanitize as T } from "../../../utils/functions/SanitizeHtmlUtils.js"; import { TRUSTED_HTML_USERS_TEAM_ID as g } from "../../../utils/SynapseConstants.js"; import { Alert as H } from "@mui/material"; import { useRef as y, useState as E, useEffect as I, useMemo as w } from "react"; import { SynapseSpinner as x } from "../../LoadingScreen/LoadingScreen.js"; function c(s) { const { rawHtml: r, isLoading: t, isTrusted: e } = s; return w(() => { if (!t) return e ? r : T(r); }, [t, e, r]); } function D(s) { const { createdByUserId: r, rawHtml: t } = s, e = y(null), [i, f] = E(100), { data: u, isLoading: m } = p( g, r ), d = () => { if (e?.current && e?.current.contentWindow) { let n = e.current.contentWindow.document.body.scrollHeight; n < 450 && (n = 450), (!i || Math.abs(n - i) > 70) && f(n + 50); } }; I(() => { setInterval(() => { d(); }, 500); }, [t]); const a = c({ rawHtml: t, isLoading: m, isTrusted: !!u }); return m ? /* @__PURE__ */ o(x, {}) : /* @__PURE__ */ l(h, { children: [ t !== a && /* @__PURE__ */ o(H, { severity: "info", sx: { marginBottom: "20px" }, children: "Limited rendering only." }), /* @__PURE__ */ o( "iframe", { ref: e, srcDoc: a, height: `${i}px`, style: { border: 0, width: "100%" } } ) ] }); } const L = { useCleanHtml: c }; export { L as EXPORTED_FOR_UNIT_TESTING, D as default }; //# sourceMappingURL=HtmlPreview.js.map