UNPKG

ranui

Version:

UI Component library based on `Web Component`

71 lines (70 loc) 2.83 kB
var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); import { c as create } from "./plus-BQnIzzvi.js"; import { c as createCustomError, H as HTMLElementSSR } from "./index-9tJmVuyv.js"; const f7170ee498e0dd32cbdcb63fba8f75cc = ".remove-wap-active-focus{outline:0;-webkit-tap-highlight-color:transparent}.remove-wap-active-focus:active,.remove-wap-active-focus:focus{outline:0;-webkit-tap-highlight-color:transparent}:host{position:var(--ran-math-position, relative)}.ran-math{display:var(--ran-math-display, flex);justify-content:var(--ran-math-justify-content, space-around);align-items:var(--ran-math-align-items, center)}.katex-html{display:var(--ran-math-katex-display, none)}"; class Math2 extends HTMLElementSSR() { constructor() { super(); __publicField(this, "contain"); this.contain = create("div").setAttribute("class", "ran-math").element; const shadowRoot = this.attachShadow({ mode: "closed" }); const F7170EE498E0DD32CBDCB63FBA8F75CC = document.createElement("style"); F7170EE498E0DD32CBDCB63FBA8F75CC.textContent = f7170ee498e0dd32cbdcb63fba8f75cc; shadowRoot.appendChild(F7170EE498E0DD32CBDCB63FBA8F75CC); shadowRoot.appendChild(this.contain); } static get observedAttributes() { return ["latex"]; } get latex() { const latex = this.getAttribute("latex") || ""; return decodeURIComponent(latex); } set latex(value) { this.setAttribute("latex", value || ""); } render() { if (!this.latex) return; import("./katex-es-CGqSCDjs.js").then((katex) => { this.contain.innerHTML = ""; const span = create("span").setTextContent(`$$${this.latex}$$`).element; this.contain.appendChild(span); if (!katex) return; katex.renderMathInElement(this.contain); }).catch(function(err) { console.warn(`ranui math component warning: ${err.message} ${err}`); }); } connectedCallback() { this.render(); } attributeChangedCallback(k, o, n) { if (o !== n) { if (k === "latex") { this.render(); } } } } async function Custom() { if (typeof document !== "undefined" && !customElements.get("r-math")) { customElements.define("r-math", Math2); return Math2; } else { return createCustomError("document is undefined or r-math is exist"); } } const index = Custom(); const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, Math: Math2, default: index }, Symbol.toStringTag, { value: "Module" })); export { Math2 as M, index as a, index$1 as i };