@elmethis/core 1.0.0-alpha.154 → 1.0.0-alpha.155

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,8 @@
1
- import { defineComponent, ref, onMounted, onUpdated, createBlock, openBlock, resolveDynamicComponent, normalizeStyle, normalizeClass, withCtx, createTextVNode, toDisplayString } from "vue";
2
- import katex from "katex";
1
+ import { defineComponent, ref, onServerPrefetch, onMounted, onUpdated, createBlock, openBlock, resolveDynamicComponent, normalizeStyle, normalizeClass, withCtx, createElementBlock, toDisplayString } from "vue";
2
+ import { renderToString } from "katex";
3
3
  /* empty css */
4
+ const _hoisted_1 = ["innerHTML"];
5
+ const _hoisted_2 = { key: 1 };
4
6
  const _sfc_main = /* @__PURE__ */ defineComponent({
5
7
  __name: "ElmKatex",
6
8
  props: {
@@ -9,32 +11,37 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
9
11
  },
10
12
  setup(__props) {
11
13
  const props = __props;
12
- const targetRef = ref(null);
14
+ const isRendered = ref(false);
15
+ const html = ref(props.expression);
13
16
  const render = () => {
14
- if (targetRef.value) {
17
+ if (!isRendered.value) {
15
18
  try {
16
- katex.render(props.expression, targetRef.value, {
19
+ html.value = renderToString(props.expression, {
17
20
  displayMode: props.block
18
21
  });
22
+ isRendered.value = true;
19
23
  } catch (err) {
20
24
  console.error("KaTeX rendering error:", err);
21
25
  }
22
26
  }
23
27
  };
28
+ onServerPrefetch(render);
24
29
  onMounted(render);
25
30
  onUpdated(render);
26
31
  return (_ctx, _cache) => {
27
32
  return openBlock(), createBlock(resolveDynamicComponent(props.block ? "div" : "span"), {
28
33
  class: normalizeClass(_ctx.$style.katex),
29
34
  key: JSON.stringify(props),
30
- ref_key: "targetRef",
31
- ref: targetRef,
35
+ ref: "targetRef",
32
36
  style: normalizeStyle({
33
37
  "--margin-block": props.block ? "3rem" : void 0
34
38
  })
35
39
  }, {
36
40
  default: withCtx(() => [
37
- createTextVNode(toDisplayString(_ctx.expression), 1)
41
+ isRendered.value ? (openBlock(), createElementBlock("span", {
42
+ key: 0,
43
+ innerHTML: html.value
44
+ }, null, 8, _hoisted_1)) : (openBlock(), createElementBlock("span", _hoisted_2, toDisplayString(_ctx.expression), 1))
38
45
  ]),
39
46
  _: 1
40
47
  }, 8, ["class", "style"]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elmethis/core",
3
- "version": "1.0.0-alpha.154",
3
+ "version": "1.0.0-alpha.155",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },