@infinilabs/markdown 0.0.4 → 0.0.6
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/markdown.js +91 -81
- package/dist/markdown.umd.cjs +2 -2
- package/package.json +2 -1
package/dist/markdown.js
CHANGED
|
@@ -1,82 +1,92 @@
|
|
|
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 p } from "react/jsx-runtime";
|
|
3
|
+
import { XMarkdown as b } from "@ant-design/x-markdown";
|
|
4
|
+
import { createCache as g, StyleProvider as w } from "@ant-design/cssinjs";
|
|
5
|
+
import C from "clsx";
|
|
6
|
+
import { Children as d, isValidElement as f, useState as T, useMemo as _, useEffect as x } from "react";
|
|
7
|
+
import { Typography as A, Table as k } from "antd";
|
|
8
|
+
import { Mermaid as N, CodeHighlighter as S } from "@ant-design/x";
|
|
9
|
+
const { Text: $ } = A, M = (t) => {
|
|
10
|
+
const { className: e, children: r } = t, c = e?.match(/language-(\w+)/)?.[1] ?? "";
|
|
11
|
+
return typeof r != "string" ? null : c === "mermaid" ? /* @__PURE__ */ p(N, { children: r }) : c ? /* @__PURE__ */ p(S, { lang: c, children: r }) : /* @__PURE__ */ p($, { code: !0, children: r });
|
|
12
|
+
}, y = (t) => typeof t == "string" || typeof t == "number" ? String(t) : f(t) ? y(t.props.children) : Array.isArray(t) ? t.map(y).join("") : "", I = (t) => {
|
|
13
|
+
const e = [], r = [], c = d.toArray(t);
|
|
14
|
+
for (const a of c) {
|
|
15
|
+
if (!f(a)) continue;
|
|
16
|
+
const s = a.type;
|
|
17
|
+
if (s === "thead") {
|
|
18
|
+
const u = d.toArray(a.props.children);
|
|
19
|
+
for (const o of u) {
|
|
20
|
+
if (!f(o)) continue;
|
|
21
|
+
const i = d.toArray(o.props.children);
|
|
22
|
+
let n = 0;
|
|
23
|
+
for (const l of i) {
|
|
24
|
+
if (!f(l)) continue;
|
|
25
|
+
const h = y(l.props.children);
|
|
26
|
+
e.push({
|
|
27
|
+
title: h,
|
|
28
|
+
dataIndex: `col_${n}`,
|
|
29
|
+
key: `col_${n}`
|
|
30
|
+
}), n++;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (s === "tbody") {
|
|
35
|
+
const u = d.toArray(a.props.children);
|
|
36
|
+
let o = 0;
|
|
37
|
+
for (const i of u) {
|
|
38
|
+
if (!f(i)) continue;
|
|
39
|
+
const n = { key: `row_${o}` }, l = d.toArray(i.props.children);
|
|
40
|
+
let h = 0;
|
|
41
|
+
for (const m of l)
|
|
42
|
+
f(m) && (n[`col_${h}`] = m.props.children, h++);
|
|
43
|
+
r.push(n), o++;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return { columns: e, dataSource: r };
|
|
48
|
+
}, j = ({ children: t }) => {
|
|
49
|
+
const { columns: e, dataSource: r } = I(t);
|
|
50
|
+
return /* @__PURE__ */ p(
|
|
51
|
+
k,
|
|
52
|
+
{
|
|
53
|
+
className: "[&_table]:w-full! [&_table]:table!",
|
|
54
|
+
columns: e,
|
|
55
|
+
dataSource: r,
|
|
56
|
+
pagination: !1,
|
|
57
|
+
size: "small",
|
|
58
|
+
bordered: !0
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
}, { Link: v } = A, X = (t) => {
|
|
62
|
+
const { url: e, requestHeaders: r, className: c, components: a, ...s } = t, [u, o] = T(s.content), i = _(() => g(), []), n = async (l) => {
|
|
63
|
+
const m = await (await fetch(l, {
|
|
64
|
+
headers: r
|
|
65
|
+
})).text();
|
|
66
|
+
o(m);
|
|
67
|
+
};
|
|
68
|
+
return x(() => {
|
|
69
|
+
e && n(e);
|
|
70
|
+
}, [e]), x(() => {
|
|
71
|
+
o(s.content);
|
|
72
|
+
}, [s.content]), /* @__PURE__ */ p(w, { cache: i, children: /* @__PURE__ */ p(
|
|
73
|
+
b,
|
|
74
|
+
{
|
|
75
|
+
...s,
|
|
76
|
+
className: C(
|
|
77
|
+
"[&_:is(h1,h2,h3,h4,h5,h6,ul,ol,p)]:[all:revert]",
|
|
78
|
+
c
|
|
79
|
+
),
|
|
80
|
+
content: u,
|
|
81
|
+
components: {
|
|
82
|
+
code: M,
|
|
83
|
+
a: v,
|
|
84
|
+
table: j,
|
|
85
|
+
...a
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
) });
|
|
89
|
+
};
|
|
90
|
+
export {
|
|
91
|
+
X as default
|
|
81
92
|
};
|
|
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("@ant-design/cssinjs"),require("clsx"),require("react"),require("antd"),require("@ant-design/x")):typeof define=="function"&&define.amd?define(["react/jsx-runtime","@ant-design/x-markdown","@ant-design/cssinjs","clsx","react","antd","@ant-design/x"],f):(e=typeof globalThis<"u"?globalThis:e||self,e.InfinilabsMarkdown=f(e.jsxRuntime,e.AntDesignXMarkdown,e.AntDesignCssinjs,e.clsx,e.React,e.antd,e.AntDesignX))})(this,(function(e,f,A,w,n,m,g){"use strict";const{Text:C}=m.Typography,k=t=>{const{className:s,children:r}=t,c=s?.match(/language-(\w+)/)?.[1]??"";return typeof r!="string"?null:c==="mermaid"?e.jsx(g.Mermaid,{children:r}):c?e.jsx(g.CodeHighlighter,{lang:c,children:r}):e.jsx(C,{code:!0,children:r})},x=t=>typeof t=="string"||typeof t=="number"?String(t):n.isValidElement(t)?x(t.props.children):Array.isArray(t)?t.map(x).join(""):"",T=t=>{const s=[],r=[],c=n.Children.toArray(t);for(const d of c){if(!n.isValidElement(d))continue;const a=d.type;if(a==="thead"){const h=n.Children.toArray(d.props.children);for(const o of h){if(!n.isValidElement(o))continue;const l=n.Children.toArray(o.props.children);let i=0;for(const u of l){if(!n.isValidElement(u))continue;const p=x(u.props.children);s.push({title:p,dataIndex:`col_${i}`,key:`col_${i}`}),i++}}}if(a==="tbody"){const h=n.Children.toArray(d.props.children);let o=0;for(const l of h){if(!n.isValidElement(l))continue;const i={key:`row_${o}`},u=n.Children.toArray(l.props.children);let p=0;for(const y of u)n.isValidElement(y)&&(i[`col_${p}`]=y.props.children,p++);r.push(i),o++}}}return{columns:s,dataSource:r}},j=({children:t})=>{const{columns:s,dataSource:r}=T(t);return e.jsx(m.Table,{className:"[&_table]:w-full! [&_table]:table!",columns:s,dataSource:r,pagination:!1,size:"small",bordered:!0})},{Link:q}=m.Typography;return t=>{const{url:s,requestHeaders:r,className:c,components:d,...a}=t,[h,o]=n.useState(a.content),l=n.useMemo(()=>A.createCache(),[]),i=async u=>{const y=await(await fetch(u,{headers:r})).text();o(y)};return n.useEffect(()=>{s&&i(s)},[s]),n.useEffect(()=>{o(a.content)},[a.content]),e.jsx(A.StyleProvider,{cache:l,children:e.jsx(f.XMarkdown,{...a,className:w("[&_:is(h1,h2,h3,h4,h5,h6,ul,ol,p)]:[all:revert]",c),content:h,components:{code:k,a:q,table:j,...d}})})}}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infinilabs/markdown",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"preview": "vite preview"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
+
"@ant-design/cssinjs": "^2.0.1",
|
|
28
29
|
"@ant-design/x": "^2.1.3",
|
|
29
30
|
"@ant-design/x-markdown": "^2.1.3",
|
|
30
31
|
"clsx": "^2.1.1"
|