markdown-flow-ui 0.2.0 → 0.2.1

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.
Files changed (26) hide show
  1. package/dist/components/ContentRender/ContentRender.stories.d.ts +1 -0
  2. package/dist/components/ContentRender/IframeSandbox.cjs.js +3 -3
  3. package/dist/components/ContentRender/IframeSandbox.cjs.js.map +1 -1
  4. package/dist/components/ContentRender/IframeSandbox.es.js +110 -109
  5. package/dist/components/ContentRender/IframeSandbox.es.js.map +1 -1
  6. package/dist/components/ContentRender/blackboard-vendor.cjs.js +1 -1
  7. package/dist/components/ContentRender/blackboard-vendor.cjs.js.map +1 -1
  8. package/dist/components/ContentRender/blackboard-vendor.es.js +14 -9
  9. package/dist/components/ContentRender/blackboard-vendor.es.js.map +1 -1
  10. package/dist/components/ContentRender/cjkFontFamily.cjs.js +2 -0
  11. package/dist/components/ContentRender/cjkFontFamily.cjs.js.map +1 -0
  12. package/dist/components/ContentRender/cjkFontFamily.d.ts +5 -0
  13. package/dist/components/ContentRender/cjkFontFamily.es.js +45 -0
  14. package/dist/components/ContentRender/cjkFontFamily.es.js.map +1 -0
  15. package/dist/components/ContentRender/cjkFontFamily.test.d.ts +1 -0
  16. package/dist/components/ContentRender/plugins/MermaidChart.cjs.js +1 -1
  17. package/dist/components/ContentRender/plugins/MermaidChart.cjs.js.map +1 -1
  18. package/dist/components/ContentRender/plugins/MermaidChart.es.js +19 -18
  19. package/dist/components/ContentRender/plugins/MermaidChart.es.js.map +1 -1
  20. package/dist/components/Slide/slideI18n.cjs.js +1 -1
  21. package/dist/components/Slide/slideI18n.cjs.js.map +1 -1
  22. package/dist/components/Slide/slideI18n.es.js +28 -32
  23. package/dist/components/Slide/slideI18n.es.js.map +1 -1
  24. package/dist/components/Slide/slideI18n.test.d.ts +1 -0
  25. package/dist/markdown-flow-ui-lib.css +1 -1
  26. package/package.json +1 -1
@@ -1,72 +1,73 @@
1
1
  import { j as M } from "../../_virtual/jsx-runtime.es.js";
2
- import W, { useRef as i, useState as y, useCallback as Le, useEffect as H, useMemo as Ue } from "react";
3
- import { createRoot as Ye } from "react-dom/client";
2
+ import W, { useRef as i, useState as y, useCallback as Ge, useEffect as H, useMemo as Ye } from "react";
3
+ import { createRoot as Ue } from "react-dom/client";
4
4
  import Xe from "./SandboxApp.es.js";
5
- import Ze from "./ContentRender.es.js";
6
- import { inspectViewportHeightFromHtmlRootString as ye, EMPTY_ROOT_HEIGHT_META as Je, parseExplicitHeight as Te, inspectViewportHeightFromNodeChain as Ke, resolveExplicitHeightFromNodeChain as Qe } from "./utils/iframe-viewport-height.es.js";
5
+ import Je from "./ContentRender.es.js";
6
+ import { inspectViewportHeightFromHtmlRootString as ye, EMPTY_ROOT_HEIGHT_META as Ke, parseExplicitHeight as Te, inspectViewportHeightFromNodeChain as Ze, resolveExplicitHeightFromNodeChain as Qe } from "./utils/iframe-viewport-height.es.js";
7
7
  import { SANDBOX_INTERACTION_MESSAGE_TYPE as et, SANDBOX_INTERACTION_MESSAGE_SOURCE as tt } from "../../lib/sandboxInteraction.es.js";
8
8
  import { injectScalingSystem as nt } from "./utils/iframe-scaling.es.js";
9
9
  import { getContentRenderLocaleTexts as rt } from "./contentRenderI18n.es.js";
10
+ import { CJK_SAFE_SANS_FONT_FAMILY as ot } from "./cjkFontFamily.es.js";
10
11
  let le = null;
11
- const ot = () => (le || (le = import("./blackboard-vendor.es.js").then(
12
+ const it = () => (le || (le = import("./blackboard-vendor.es.js").then(
12
13
  (c) => c.injectBlackboardLibraries
13
- )), le), it = /<img\b[^>]*>/i, st = 180, ct = 240, lt = (c) => c.split(/\s+/).filter(Boolean).map((o) => {
14
+ )), le), st = /<img\b[^>]*>/i, ct = 180, lt = 240, at = (c) => c.split(/\s+/).filter(Boolean).map((o) => {
14
15
  const s = o.split(":");
15
16
  return s[s.length - 1] !== "h-screen" && s[s.length - 1] !== "min-h-screen" ? o : (s[s.length - 1] = "h-full", s.join(":"));
16
- }).join(" "), at = (c, o) => !o || !c.trim() ? c : c.replace(
17
+ }).join(" "), ut = (c, o) => !o || !c.trim() ? c : c.replace(
17
18
  /^(\s*<[a-zA-Z][\w:-]*)(\s[^>]*?)?>/,
18
- (s, S, T = "") => {
19
+ (s, E, T = "") => {
19
20
  const h = T.match(/\bclass\s*=\s*(["'])([^"']*)\1/i);
20
21
  if (!h)
21
22
  return s;
22
- const A = lt(h[2]);
23
- return A === h[2] ? s : `${S}${T.replace(
23
+ const A = at(h[2]);
24
+ return A === h[2] ? s : `${E}${T.replace(
24
25
  h[0],
25
26
  `class=${h[1]}${A}${h[1]}`
26
27
  )}>`;
27
28
  }
28
- ), xt = ({
29
+ ), St = ({
29
30
  content: c,
30
31
  type: o,
31
32
  className: s,
32
- locale: S,
33
+ locale: E,
33
34
  loadingText: T,
34
35
  styleLoadingText: h,
35
36
  scriptLoadingText: A,
36
37
  fullScreenButtonText: Ae,
37
- exitFullScreenButtonText: ke,
38
- hideFullScreen: _e = !1,
38
+ exitFullScreenButtonText: _e,
39
+ hideFullScreen: Fe = !1,
39
40
  mode: a = "content",
40
- replaceRootScreenHeightWithFull: Fe = !1,
41
+ replaceRootScreenHeightWithFull: ke = !1,
41
42
  enableScaling: Ie = !1,
42
- disableLoadingOverlay: Y = !1
43
+ disableLoadingOverlay: U = !1
43
44
  }) => {
44
- const ae = rt(S), Ne = Ae || ae.sandboxFullscreenButtonText, Be = ke || ae.sandboxExitFullscreenButtonText, D = i(null), f = i(null), X = i(null), k = i(() => {
45
- }), [Oe, Ve] = y(480), [ue, je] = y(0), [Z, he] = y(0), J = i(!1), K = i(!1), de = i(0), [me, We] = y(0), [Q, De] = y(!1), Pe = o === "sandbox", g = a === "blackboard", b = Ie && g && o === "sandbox", _ = g && o === "sandbox", R = _ && Fe, ee = i(""), P = W.useMemo(
45
+ const ae = rt(E), Ne = Ae || ae.sandboxFullscreenButtonText, Oe = _e || ae.sandboxExitFullscreenButtonText, D = i(null), f = i(null), X = i(null), _ = i(() => {
46
+ }), [Be, Ve] = y(480), [ue, je] = y(0), [J, he] = y(0), K = i(!1), Z = i(!1), de = i(0), [me, We] = y(0), [Q, De] = y(!1), Pe = o === "sandbox", g = a === "blackboard", b = Ie && g && o === "sandbox", F = g && o === "sandbox", C = F && ke, ee = i(""), P = W.useMemo(
46
47
  () => o === "sandbox" ? c : "",
47
48
  [c, o]
48
49
  ), n = W.useMemo(
49
- () => at(
50
+ () => ut(
50
51
  P,
51
- R
52
+ C
52
53
  ),
53
- [P, R]
54
+ [P, C]
54
55
  ), fe = W.useMemo(
55
- () => R ? ye(P) : Je,
56
- [P, R]
56
+ () => C ? ye(P) : Ke,
57
+ [P, C]
57
58
  ), te = W.useMemo(
58
- () => R && fe.hasFullViewportHeight,
59
+ () => C && fe.hasFullViewportHeight,
59
60
  [
60
61
  fe.hasFullViewportHeight,
61
- R
62
+ C
62
63
  ]
63
64
  ), [$, ge] = y(
64
65
  n
65
- ), be = i(n), ne = i(n), F = i(null), I = i(null), pe = i(null), He = Le((t) => {
66
+ ), be = i(n), ne = i(n), k = i(null), I = i(null), pe = i(null), He = Ge((t) => {
66
67
  if (typeof window > "u")
67
68
  return;
68
69
  const e = Date.now();
69
- e - de.current < ct || (de.current = e, window.postMessage(
70
+ e - de.current < lt || (de.current = e, window.postMessage(
70
71
  {
71
72
  source: tt,
72
73
  type: et,
@@ -75,7 +76,7 @@ const ot = () => (le || (le = import("./blackboard-vendor.es.js").then(
75
76
  window.location.origin
76
77
  ));
77
78
  }, []), re = () => {
78
- F.current !== null && (window.clearTimeout(F.current), F.current = null);
79
+ k.current !== null && (window.clearTimeout(k.current), k.current = null);
79
80
  }, $e = () => {
80
81
  I.current !== null && (window.cancelAnimationFrame(I.current), I.current = null);
81
82
  };
@@ -87,22 +88,22 @@ const ot = () => (le || (le = import("./blackboard-vendor.es.js").then(
87
88
  ), H(() => {
88
89
  const t = be.current;
89
90
  be.current = n;
90
- const e = !!t && n.length > t.length && n.startsWith(t), u = it.test(
91
+ const e = !!t && n.length > t.length && n.startsWith(t), u = st.test(
91
92
  n
92
93
  );
93
94
  if (!(e && u)) {
94
95
  re(), ne.current = n, ge(n);
95
96
  return;
96
97
  }
97
- ne.current = n, re(), F.current = window.setTimeout(() => {
98
- ge(ne.current), F.current = null;
99
- }, st);
98
+ ne.current = n, re(), k.current = window.setTimeout(() => {
99
+ ge(ne.current), k.current = null;
100
+ }, ct);
100
101
  }, [n]);
101
- const z = W.useMemo(() => _ ? ye($).viewportHeightCss : null, [$, _]);
102
+ const z = W.useMemo(() => F ? ye($).viewportHeightCss : null, [$, F]);
102
103
  H(() => {
103
104
  pe.current = z;
104
105
  }, [z]);
105
- const oe = !!z, N = g && o === "sandbox" ? b || te ? "100%" : z ?? `${Oe}px` : void 0;
106
+ const oe = !!z, N = g && o === "sandbox" ? b || te ? "100%" : z ?? `${Be}px` : void 0;
106
107
  H(() => {
107
108
  if (a !== "blackboard") {
108
109
  ee.current = n;
@@ -122,7 +123,7 @@ const ot = () => (le || (le = import("./blackboard-vendor.es.js").then(
122
123
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
123
124
  <style>
124
125
  :root { color-scheme: light; }
125
- html, body, #root { width: 100%; }
126
+ html, body, #root { width: 100%; font-family: ${ot}; }
126
127
  ${a === "blackboard" ? "html, body, #root { height: 100%; }" : ""}
127
128
  html, body { margin: 0; padding: 0; overflow: ${b ? "hidden auto" : a === "blackboard" ? "auto" : "hidden"}; }
128
129
  *, *::before, *::after { box-sizing: border-box; }
@@ -138,42 +139,42 @@ const ot = () => (le || (le = import("./blackboard-vendor.es.js").then(
138
139
  <div id="root"></div>
139
140
  </body>
140
141
  </html>`), e.close(), e.documentElement.setAttribute("data-theme", "light"), e.documentElement.style.colorScheme = "light", e.body?.style.setProperty("color-scheme", "light");
141
- const u = g && o === "sandbox", q = () => He("click");
142
- u && e.addEventListener("click", q, !0);
143
- const B = e.getElementById("root");
144
- if (!B) return;
145
- const we = Ye(B);
142
+ const u = g && o === "sandbox", L = () => He("click");
143
+ u && e.addEventListener("click", L, !0);
144
+ const O = e.getElementById("root");
145
+ if (!O) return;
146
+ const we = Ue(O);
146
147
  X.current = we;
147
- let O = !1;
148
- const ve = (r) => ({
148
+ let B = !1;
149
+ const Se = (r) => ({
149
150
  heightAttrValue: r.getAttribute("height"),
150
151
  styleAttrValue: r.getAttribute("style"),
151
152
  classAttrValue: r.getAttribute("class")
152
- }), Ee = (r) => {
153
+ }), ve = (r) => {
153
154
  const x = Array.from(r.children);
154
155
  return x.length === 1 ? x[0] : null;
155
- }, Ge = () => {
156
- if (!_ || !f.current || !e.body) return null;
157
- const r = f.current.ownerDocument?.documentElement?.clientHeight || window.innerHeight, x = pe.current, G = x ? Te(
156
+ }, qe = () => {
157
+ if (!F || !f.current || !e.body) return null;
158
+ const r = f.current.ownerDocument?.documentElement?.clientHeight || window.innerHeight, x = pe.current, q = x ? Te(
158
159
  x,
159
160
  r
160
161
  ) : null;
161
- if (G !== null)
162
- return Math.ceil(G);
162
+ if (q !== null)
163
+ return Math.ceil(q);
163
164
  const d = e.body.querySelector(
164
165
  ".sandbox-wrapper"
165
166
  )?.firstElementChild;
166
167
  if (!d) return null;
167
- const m = Array.from(d.children), w = m.length === 1 ? m[0] : null, L = Ke(
168
+ const m = Array.from(d.children), w = m.length === 1 ? m[0] : null, G = Ze(
168
169
  w,
169
170
  {
170
- getNode: ve,
171
- getSingleChild: Ee
171
+ getNode: Se,
172
+ getSingleChild: ve
172
173
  }
173
174
  ).viewportHeightCss;
174
- if (L) {
175
+ if (G) {
175
176
  const V = Te(
176
- L,
177
+ G,
177
178
  r
178
179
  );
179
180
  if (V !== null)
@@ -183,100 +184,100 @@ const ot = () => (le || (le = import("./blackboard-vendor.es.js").then(
183
184
  w,
184
185
  r,
185
186
  {
186
- getNode: ve,
187
- getSingleChild: Ee
187
+ getNode: Se,
188
+ getSingleChild: ve
188
189
  }
189
190
  );
190
191
  return l !== null ? Math.ceil(l) : null;
191
192
  }, ie = () => {
192
193
  if (!f.current || !e.body) return;
193
194
  if (!g) {
194
- if (J.current) {
195
- K.current = !0;
195
+ if (K.current) {
196
+ Z.current = !0;
196
197
  return;
197
198
  }
198
- J.current = !0;
199
+ K.current = !0;
199
200
  const d = f.current, m = D.current?.clientWidth || 0, w = d.style.height;
200
201
  if (m > 0) {
201
- const ce = Math.round(m * 9 / 16), L = Math.max(8192, m * 20);
202
+ const ce = Math.round(m * 9 / 16), G = Math.max(8192, m * 20);
202
203
  d.style.height = ce + "px", e.body.offsetHeight;
203
204
  let l = e.body.scrollHeight;
204
205
  const V = e.defaultView;
205
206
  if (V) {
206
207
  const j = (p) => {
207
- let v = 0;
208
- const Ce = (E) => {
209
- if (E !== p && E.scrollHeight > E.clientHeight + 1) {
210
- const U = V.getComputedStyle(E).overflowY;
211
- if (U === "auto" || U === "scroll") {
212
- const Me = E.getBoundingClientRect();
213
- Me.top >= 0 && (v = Math.max(
214
- v,
215
- Math.ceil(Me.top + E.scrollHeight)
208
+ let S = 0;
209
+ const Re = (v) => {
210
+ if (v !== p && v.scrollHeight > v.clientHeight + 1) {
211
+ const Y = V.getComputedStyle(v).overflowY;
212
+ if (Y === "auto" || Y === "scroll") {
213
+ const Me = v.getBoundingClientRect();
214
+ Me.top >= 0 && (S = Math.max(
215
+ S,
216
+ Math.ceil(Me.top + v.scrollHeight)
216
217
  ));
217
218
  }
218
219
  }
219
- for (const U of E.children) Ce(U);
220
+ for (const Y of v.children) Re(Y);
220
221
  };
221
- return Ce(p), v;
222
+ return Re(p), S;
222
223
  };
223
224
  l = Math.max(l, j(e.body));
224
225
  for (let p = 0; p < 8 && l > ce; p++) {
225
226
  d.style.height = l + "px", e.body.offsetHeight;
226
- const v = Math.max(
227
+ const S = Math.max(
227
228
  e.body.scrollHeight,
228
229
  j(e.body)
229
230
  );
230
- if (v <= l + 1 || v >= l * 1.5) break;
231
- l = v;
231
+ if (S <= l + 1 || S >= l * 1.5) break;
232
+ l = S;
232
233
  }
233
234
  }
234
235
  d.style.height = w, je((j) => {
235
- const p = Math.min(L, Math.max(200, Math.ceil(l)));
236
+ const p = Math.min(G, Math.max(200, Math.ceil(l)));
236
237
  return j === p ? j : p;
237
238
  });
238
239
  }
239
240
  setTimeout(() => {
240
- J.current = !1, K.current && (K.current = !1, C());
241
+ K.current = !1, Z.current && (Z.current = !1, R());
241
242
  }, 50);
242
243
  return;
243
244
  }
244
245
  if (b) return;
245
- const r = e.body.scrollHeight, x = e.documentElement?.scrollHeight || 0, G = B?.scrollHeight || 0, Re = Math.max(r, x, G);
246
- if (_) {
247
- const d = Ge(), m = Math.max(
246
+ const r = e.body.scrollHeight, x = e.documentElement?.scrollHeight || 0, q = O?.scrollHeight || 0, Ce = Math.max(r, x, q);
247
+ if (F) {
248
+ const d = qe(), m = Math.max(
248
249
  200,
249
- d ?? Math.ceil(Re)
250
+ d ?? Math.ceil(Ce)
250
251
  );
251
252
  Ve(
252
253
  (w) => w === m ? w : m
253
254
  );
254
255
  }
255
- }, C = () => {
256
+ }, R = () => {
256
257
  requestAnimationFrame(() => {
257
- O || ie();
258
+ B || ie();
258
259
  });
259
260
  };
260
- k.current = C, ie(), C(), Pe && ot().then((r) => {
261
- O || (r(e), b && nt(e), requestAnimationFrame(() => {
262
- O || C();
261
+ _.current = R, ie(), R(), Pe && it().then((r) => {
262
+ B || (r(e), b && nt(e), requestAnimationFrame(() => {
263
+ B || R();
263
264
  }));
264
265
  }).catch(() => {
265
- O || C();
266
+ B || R();
266
267
  });
267
268
  const se = new ResizeObserver(() => ie());
268
- se.observe(e.body), B && se.observe(B);
269
- const Se = new MutationObserver(() => {
270
- C();
269
+ se.observe(e.body), O && se.observe(O);
270
+ const Ee = new MutationObserver(() => {
271
+ R();
271
272
  });
272
- return Se.observe(e.body, {
273
+ return Ee.observe(e.body, {
273
274
  childList: !0,
274
275
  subtree: !0,
275
276
  attributes: !0,
276
277
  attributeFilter: ["style", "class"]
277
278
  }), () => {
278
- O = !0, se.disconnect(), Se.disconnect(), b && t.contentWindow?.__mdf_cleanupScaling?.(), u && e.removeEventListener("click", q, !0), setTimeout(() => {
279
- we.unmount(), X.current = null, k.current = () => {
279
+ B = !0, se.disconnect(), Ee.disconnect(), b && t.contentWindow?.__mdf_cleanupScaling?.(), u && e.removeEventListener("click", L, !0), setTimeout(() => {
280
+ we.unmount(), X.current = null, _.current = () => {
280
281
  };
281
282
  }, 0);
282
283
  };
@@ -293,12 +294,12 @@ const ot = () => (le || (le = import("./blackboard-vendor.es.js").then(
293
294
  });
294
295
  return e.observe(t), he(t.clientWidth), () => e.disconnect();
295
296
  }, []);
296
- const xe = Ue(() => {
297
- if (g || Z === 0 || Q)
297
+ const xe = Ye(() => {
298
+ if (g || J === 0 || Q)
298
299
  return;
299
- const t = Math.round(Z * 9 / 16);
300
+ const t = Math.round(J * 9 / 16);
300
301
  return { height: Math.max(t, ue) };
301
- }, [g, Z, ue, Q]), ze = () => {
302
+ }, [g, J, ue, Q]), ze = () => {
302
303
  const t = D.current || f.current;
303
304
  if (t) {
304
305
  if (document.fullscreenElement) {
@@ -318,11 +319,11 @@ const ot = () => (le || (le = import("./blackboard-vendor.es.js").then(
318
319
  Xe,
319
320
  {
320
321
  html: $,
321
- locale: S,
322
+ locale: E,
322
323
  loadingText: T,
323
324
  styleLoadingText: h,
324
325
  scriptLoadingText: A,
325
- disableLoadingOverlay: Y,
326
+ disableLoadingOverlay: U,
326
327
  resetToken: me,
327
328
  hasRootVhHeight: oe,
328
329
  mode: a,
@@ -331,26 +332,26 @@ const ot = () => (le || (le = import("./blackboard-vendor.es.js").then(
331
332
  }
332
333
  )
333
334
  ), I.current = window.requestAnimationFrame(() => {
334
- k.current?.(), b && f.current?.contentWindow?.__mdf_triggerFitContent?.(), I.current = null;
335
+ _.current?.(), b && f.current?.contentWindow?.__mdf_triggerFitContent?.(), I.current = null;
335
336
  });
336
- const e = setTimeout(() => k.current?.(), 100), u = setTimeout(() => k.current?.(), 500);
337
+ const e = setTimeout(() => _.current?.(), 100), u = setTimeout(() => _.current?.(), 500);
337
338
  return () => {
338
339
  clearTimeout(e), clearTimeout(u);
339
340
  };
340
341
  }, [
341
342
  $,
342
- S,
343
+ E,
343
344
  T,
344
345
  h,
345
346
  A,
346
347
  me,
347
- Y,
348
+ U,
348
349
  oe,
349
350
  a,
350
351
  te,
351
352
  b
352
353
  ]);
353
- const qe = [
354
+ const Le = [
354
355
  "w-full relative content-render-iframe-sandbox",
355
356
  g ? "h-full overflow-auto flex flex-col" : xe ? "overflow-hidden flex items-center justify-center" : "aspect-[16/9] overflow-hidden flex items-center justify-center"
356
357
  ].filter(Boolean).join(" ");
@@ -359,27 +360,27 @@ const ot = () => (le || (le = import("./blackboard-vendor.es.js").then(
359
360
  {
360
361
  ref: D,
361
362
  "data-root-vh": oe ? "true" : "false",
362
- className: qe,
363
+ className: Le,
363
364
  style: N ? {
364
365
  height: N,
365
366
  minHeight: N
366
367
  } : xe,
367
368
  children: [
368
- !_e && /* @__PURE__ */ M.jsx(
369
+ !Fe && /* @__PURE__ */ M.jsx(
369
370
  "button",
370
371
  {
371
372
  type: "button",
372
373
  onClick: ze,
373
374
  className: "absolute top-2 right-2 z-50 p-1.5 bg-black/75 text-white rounded-md cursor-pointer",
374
- children: Q ? Be : Ne
375
+ children: Q ? Oe : Ne
375
376
  }
376
377
  ),
377
378
  a === "blackboard" && o === "markdown" ? /* @__PURE__ */ M.jsx("div", { onClick: () => He("click"), children: /* @__PURE__ */ M.jsx(
378
- Ze,
379
+ Je,
379
380
  {
380
381
  content: c,
381
- locale: S,
382
- disableSandboxLoadingOverlay: Y
382
+ locale: E,
383
+ disableSandboxLoadingOverlay: U
383
384
  }
384
385
  ) }) : /* @__PURE__ */ M.jsx(
385
386
  "iframe",
@@ -401,6 +402,6 @@ const ot = () => (le || (le = import("./blackboard-vendor.es.js").then(
401
402
  );
402
403
  };
403
404
  export {
404
- xt as default
405
+ St as default
405
406
  };
406
407
  //# sourceMappingURL=IframeSandbox.es.js.map