@infinilabs/markdown 0.0.3 → 0.0.5
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.
- package/dist/index.d.ts +1 -0
- package/dist/markdown.js +90 -81
- package/dist/markdown.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/markdown.js
CHANGED
|
@@ -1,82 +1,91 @@
|
|
|
1
|
-
(function(){try{if(typeof document
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var n=document.createElement("style");n.appendChild(document.createTextNode("*,:before,:after{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }::backdrop{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }.\\[\\&_\\:is\\(h1\\,h2\\,h3\\,h4\\,h5\\,h6\\,ul\\,ol\\,p\\)\\]\\:\\[all\\:revert\\] :is(h1,h2,h3,h4,h5,h6,ul,ol,p){all:revert}.\\[\\&_table\\]\\:w-full\\! table{width:100%!important}.\\[\\&_table\\]\\:table\\! table{display:table!important}.table{display:table}")),document.head.appendChild(n)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
|
|
2
|
+
import { jsx as h } from "react/jsx-runtime";
|
|
3
|
+
import { XMarkdown as b } from "@ant-design/x-markdown";
|
|
4
|
+
import g from "clsx";
|
|
5
|
+
import { Children as d, isValidElement as f, useState as w, useEffect as x } from "react";
|
|
6
|
+
import { Typography as A, Table as T } from "antd";
|
|
7
|
+
import { Mermaid as _, CodeHighlighter as C } from "@ant-design/x";
|
|
8
|
+
const { Text: k } = A, N = (t) => {
|
|
9
|
+
const { className: e, children: r } = t, s = e?.match(/language-(\w+)/)?.[1] ?? "";
|
|
10
|
+
return typeof r != "string" ? null : s === "mermaid" ? /* @__PURE__ */ h(_, { children: r }) : s ? /* @__PURE__ */ h(C, { lang: s, children: r }) : /* @__PURE__ */ h(k, { code: !0, children: r });
|
|
11
|
+
}, m = (t) => typeof t == "string" || typeof t == "number" ? String(t) : f(t) ? m(t.props.children) : Array.isArray(t) ? t.map(m).join("") : "", $ = (t) => {
|
|
12
|
+
const e = [], r = [], s = d.toArray(t);
|
|
13
|
+
for (const a of s) {
|
|
14
|
+
if (!f(a)) continue;
|
|
15
|
+
const c = a.type;
|
|
16
|
+
if (c === "thead") {
|
|
17
|
+
const p = d.toArray(a.props.children);
|
|
18
|
+
for (const o of p) {
|
|
19
|
+
if (!f(o)) continue;
|
|
20
|
+
const i = d.toArray(o.props.children);
|
|
21
|
+
let n = 0;
|
|
22
|
+
for (const u of i) {
|
|
23
|
+
if (!f(u)) continue;
|
|
24
|
+
const l = m(u.props.children);
|
|
25
|
+
e.push({
|
|
26
|
+
title: l,
|
|
27
|
+
dataIndex: `col_${n}`,
|
|
28
|
+
key: `col_${n}`
|
|
29
|
+
}), n++;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (c === "tbody") {
|
|
34
|
+
const p = d.toArray(a.props.children);
|
|
35
|
+
let o = 0;
|
|
36
|
+
for (const i of p) {
|
|
37
|
+
if (!f(i)) continue;
|
|
38
|
+
const n = { key: `row_${o}` }, u = d.toArray(i.props.children);
|
|
39
|
+
let l = 0;
|
|
40
|
+
for (const y of u)
|
|
41
|
+
f(y) && (n[`col_${l}`] = y.props.children, l++);
|
|
42
|
+
r.push(n), o++;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return { columns: e, dataSource: r };
|
|
47
|
+
}, S = ({ children: t }) => {
|
|
48
|
+
const { columns: e, dataSource: r } = $(t);
|
|
49
|
+
return /* @__PURE__ */ h(
|
|
50
|
+
T,
|
|
51
|
+
{
|
|
52
|
+
className: "[&_table]:w-full! [&_table]:table!",
|
|
53
|
+
columns: e,
|
|
54
|
+
dataSource: r,
|
|
55
|
+
pagination: !1,
|
|
56
|
+
size: "small",
|
|
57
|
+
bordered: !0
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
}, { Link: I } = A, z = (t) => {
|
|
61
|
+
const { url: e, requestHeaders: r, className: s, components: a, ...c } = t, [p, o] = w(c.content), i = async (n) => {
|
|
62
|
+
const l = await (await fetch(n, {
|
|
63
|
+
headers: r
|
|
64
|
+
})).text();
|
|
65
|
+
o(l);
|
|
66
|
+
};
|
|
67
|
+
return x(() => {
|
|
68
|
+
e && i(e);
|
|
69
|
+
}, [e]), x(() => {
|
|
70
|
+
o(c.content);
|
|
71
|
+
}, [c.content]), /* @__PURE__ */ h(
|
|
72
|
+
b,
|
|
73
|
+
{
|
|
74
|
+
...c,
|
|
75
|
+
className: g(
|
|
76
|
+
"[&_:is(h1,h2,h3,h4,h5,h6,ul,ol,p)]:[all:revert]",
|
|
77
|
+
s
|
|
78
|
+
),
|
|
79
|
+
content: p,
|
|
80
|
+
components: {
|
|
81
|
+
code: N,
|
|
82
|
+
a: I,
|
|
83
|
+
table: S,
|
|
84
|
+
...a
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
};
|
|
89
|
+
export {
|
|
90
|
+
z as default
|
|
81
91
|
};
|
|
82
|
-
export { components_default as default };
|
package/dist/markdown.umd.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){try{if(typeof document
|
|
2
|
-
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var n=document.createElement("style");n.appendChild(document.createTextNode("*,:before,:after{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }::backdrop{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }.\\[\\&_\\:is\\(h1\\,h2\\,h3\\,h4\\,h5\\,h6\\,ul\\,ol\\,p\\)\\]\\:\\[all\\:revert\\] :is(h1,h2,h3,h4,h5,h6,ul,ol,p){all:revert}.\\[\\&_table\\]\\:w-full\\! table{width:100%!important}.\\[\\&_table\\]\\:table\\! table{display:table!important}.table{display:table}")),document.head.appendChild(n)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
|
|
2
|
+
(function(e,f){typeof exports=="object"&&typeof module<"u"?module.exports=f(require("react/jsx-runtime"),require("@ant-design/x-markdown"),require("clsx"),require("react"),require("antd"),require("@ant-design/x")):typeof define=="function"&&define.amd?define(["react/jsx-runtime","@ant-design/x-markdown","clsx","react","antd","@ant-design/x"],f):(e=typeof globalThis<"u"?globalThis:e||self,e.InfinilabsMarkdown=f(e.jsxRuntime,e.AntDesignXMarkdown,e.clsx,e.React,e.antd,e.AntDesignX))})(this,(function(e,f,A,t,m,x){"use strict";const{Text:g}=m.Typography,k=n=>{const{className:s,children:r}=n,c=s?.match(/language-(\w+)/)?.[1]??"";return typeof r!="string"?null:c==="mermaid"?e.jsx(x.Mermaid,{children:r}):c?e.jsx(x.CodeHighlighter,{lang:c,children:r}):e.jsx(g,{code:!0,children:r})},y=n=>typeof n=="string"||typeof n=="number"?String(n):t.isValidElement(n)?y(n.props.children):Array.isArray(n)?n.map(y).join(""):"",C=n=>{const s=[],r=[],c=t.Children.toArray(n);for(const d of c){if(!t.isValidElement(d))continue;const a=d.type;if(a==="thead"){const h=t.Children.toArray(d.props.children);for(const o of h){if(!t.isValidElement(o))continue;const l=t.Children.toArray(o.props.children);let i=0;for(const p of l){if(!t.isValidElement(p))continue;const u=y(p.props.children);s.push({title:u,dataIndex:`col_${i}`,key:`col_${i}`}),i++}}}if(a==="tbody"){const h=t.Children.toArray(d.props.children);let o=0;for(const l of h){if(!t.isValidElement(l))continue;const i={key:`row_${o}`},p=t.Children.toArray(l.props.children);let u=0;for(const w of p)t.isValidElement(w)&&(i[`col_${u}`]=w.props.children,u++);r.push(i),o++}}}return{columns:s,dataSource:r}},T=({children:n})=>{const{columns:s,dataSource:r}=C(n);return e.jsx(m.Table,{className:"[&_table]:w-full! [&_table]:table!",columns:s,dataSource:r,pagination:!1,size:"small",bordered:!0})},{Link:E}=m.Typography;return n=>{const{url:s,requestHeaders:r,className:c,components:d,...a}=n,[h,o]=t.useState(a.content),l=async i=>{const u=await(await fetch(i,{headers:r})).text();o(u)};return t.useEffect(()=>{s&&l(s)},[s]),t.useEffect(()=>{o(a.content)},[a.content]),e.jsx(f.XMarkdown,{...a,className:A("[&_:is(h1,h2,h3,h4,h5,h6,ul,ol,p)]:[all:revert]",c),content:h,components:{code:k,a:E,table:T,...d}})}}));
|