@infinilabs/markdown 0.0.2 → 0.0.4
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 +81 -85
- package/dist/markdown.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/markdown.js
CHANGED
|
@@ -1,86 +1,82 @@
|
|
|
1
|
-
(function(){
|
|
2
|
-
import {
|
|
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
|
-
|
|
81
|
-
}
|
|
82
|
-
);
|
|
83
|
-
};
|
|
84
|
-
export {
|
|
85
|
-
L as default
|
|
1
|
+
(function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.appendChild(document.createTextNode(`*,:before,:after,::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 #0000;--un-ring-shadow:0 0 #0000;--un-shadow-inset: ;--un-shadow:0 0 #0000;--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:#93c5fd80;--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}
|
|
2
|
+
/*$vite$:1*/`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();import { XMarkdown } from "@ant-design/x-markdown";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import { Children, isValidElement, useEffect, useState } from "react";
|
|
5
|
+
import { Table, Typography } from "antd";
|
|
6
|
+
import { CodeHighlighter, Mermaid } from "@ant-design/x";
|
|
7
|
+
import { jsx } from "react/jsx-runtime";
|
|
8
|
+
var { Text } = Typography, Code_default = (e) => {
|
|
9
|
+
let { className: o, children: s } = e, c = o?.match(/language-(\w+)/)?.[1] ?? "";
|
|
10
|
+
return typeof s == "string" ? c === "mermaid" ? /* @__PURE__ */ jsx(Mermaid, { children: s }) : c ? /* @__PURE__ */ jsx(CodeHighlighter, {
|
|
11
|
+
lang: c,
|
|
12
|
+
children: s
|
|
13
|
+
}) : /* @__PURE__ */ jsx(Text, {
|
|
14
|
+
code: !0,
|
|
15
|
+
children: s
|
|
16
|
+
}) : null;
|
|
17
|
+
}, extractText = (e) => typeof e == "string" || typeof e == "number" ? String(e) : isValidElement(e) ? extractText(e.props.children) : Array.isArray(e) ? e.map(extractText).join("") : "", parseTableChildren = (e) => {
|
|
18
|
+
let o = [], l = [], u = Children.toArray(e);
|
|
19
|
+
for (let e of u) {
|
|
20
|
+
if (!isValidElement(e)) continue;
|
|
21
|
+
let u = e.type;
|
|
22
|
+
if (u === "thead") {
|
|
23
|
+
let l = Children.toArray(e.props.children);
|
|
24
|
+
for (let e of l) {
|
|
25
|
+
if (!isValidElement(e)) continue;
|
|
26
|
+
let l = Children.toArray(e.props.children), u = 0;
|
|
27
|
+
for (let e of l) {
|
|
28
|
+
if (!isValidElement(e)) continue;
|
|
29
|
+
let s = extractText(e.props.children);
|
|
30
|
+
o.push({
|
|
31
|
+
title: s,
|
|
32
|
+
dataIndex: `col_${u}`,
|
|
33
|
+
key: `col_${u}`
|
|
34
|
+
}), u++;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (u === "tbody") {
|
|
39
|
+
let o = Children.toArray(e.props.children), u = 0;
|
|
40
|
+
for (let e of o) {
|
|
41
|
+
if (!isValidElement(e)) continue;
|
|
42
|
+
let o = { key: `row_${u}` }, d = Children.toArray(e.props.children), f = 0;
|
|
43
|
+
for (let e of d) isValidElement(e) && (o[`col_${f}`] = e.props.children, f++);
|
|
44
|
+
l.push(o), u++;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
columns: o,
|
|
50
|
+
dataSource: l
|
|
51
|
+
};
|
|
52
|
+
}, Table_default = ({ children: e }) => {
|
|
53
|
+
let { columns: o, dataSource: s } = parseTableChildren(e);
|
|
54
|
+
return /* @__PURE__ */ jsx(Table, {
|
|
55
|
+
className: "[&_table]:w-full! [&_table]:table!",
|
|
56
|
+
columns: o,
|
|
57
|
+
dataSource: s,
|
|
58
|
+
pagination: !1,
|
|
59
|
+
size: "small",
|
|
60
|
+
bordered: !0
|
|
61
|
+
});
|
|
62
|
+
}, { Link } = Typography, components_default = (s) => {
|
|
63
|
+
let { url: c, requestHeaders: d, className: f, components: p, ...m } = s, [h, g] = useState(m.content), _ = async (e) => {
|
|
64
|
+
g(await (await fetch(e, { headers: d })).text());
|
|
65
|
+
};
|
|
66
|
+
return useEffect(() => {
|
|
67
|
+
c && _(c);
|
|
68
|
+
}, [c]), useEffect(() => {
|
|
69
|
+
g(m.content);
|
|
70
|
+
}, [m.content]), /* @__PURE__ */ jsx(XMarkdown, {
|
|
71
|
+
...m,
|
|
72
|
+
className: clsx("[&_:is(h1,h2,h3,h4,h5,h6,ul,ol,p)]:[all:revert]", f),
|
|
73
|
+
content: h,
|
|
74
|
+
components: {
|
|
75
|
+
code: Code_default,
|
|
76
|
+
a: Link,
|
|
77
|
+
table: Table_default,
|
|
78
|
+
...p
|
|
79
|
+
}
|
|
80
|
+
});
|
|
86
81
|
};
|
|
82
|
+
export { components_default as default };
|
package/dist/markdown.umd.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(){
|
|
2
|
-
(function(e,
|
|
1
|
+
(function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.appendChild(document.createTextNode(`*,:before,:after,::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 #0000;--un-ring-shadow:0 0 #0000;--un-shadow-inset: ;--un-shadow:0 0 #0000;--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:#93c5fd80;--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}
|
|
2
|
+
/*$vite$:1*/`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();(function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t(require(`@ant-design/x-markdown`),require(`clsx`),require(`react`),require(`antd`),require(`@ant-design/x`),require(`react/jsx-runtime`)):typeof define==`function`&&define.amd?define([`@ant-design/x-markdown`,`clsx`,`react`,`antd`,`@ant-design/x`,`react/jsx-runtime`],t):(e=typeof globalThis<`u`?globalThis:e||self,e.InfinilabsMarkdown=t(e.AntDesignXMarkdown,e.clsx,e.React,e.antd,e.AntDesignX,e.jsxRuntime))})(this,function(e,t,n,r,i,a){var o=Object.create,s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,u=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty,f=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=l(t),a=0,o=i.length,u;a<o;a++)u=i[a],!d.call(e,u)&&u!==n&&s(e,u,{get:(e=>t[e]).bind(null,u),enumerable:!(r=c(t,u))||r.enumerable});return e};t=((e,t,n)=>(n=e==null?{}:o(u(e)),f(t||!e||!e.__esModule?s(n,`default`,{value:e,enumerable:!0}):n,e)))(t);var{Text:p}=r.Typography,m=e=>{let{className:t,children:n}=e,r=t?.match(/language-(\w+)/)?.[1]??``;return typeof n==`string`?r===`mermaid`?(0,a.jsx)(i.Mermaid,{children:n}):r?(0,a.jsx)(i.CodeHighlighter,{lang:r,children:n}):(0,a.jsx)(p,{code:!0,children:n}):null},h=e=>typeof e==`string`||typeof e==`number`?String(e):(0,n.isValidElement)(e)?h(e.props.children):Array.isArray(e)?e.map(h).join(``):``,g=e=>{let t=[],r=[],i=n.Children.toArray(e);for(let e of i){if(!(0,n.isValidElement)(e))continue;let i=e.type;if(i===`thead`){let r=n.Children.toArray(e.props.children);for(let e of r){if(!(0,n.isValidElement)(e))continue;let r=n.Children.toArray(e.props.children),i=0;for(let e of r){if(!(0,n.isValidElement)(e))continue;let r=h(e.props.children);t.push({title:r,dataIndex:`col_${i}`,key:`col_${i}`}),i++}}}if(i===`tbody`){let t=n.Children.toArray(e.props.children),i=0;for(let e of t){if(!(0,n.isValidElement)(e))continue;let t={key:`row_${i}`},a=n.Children.toArray(e.props.children),o=0;for(let e of a)(0,n.isValidElement)(e)&&(t[`col_${o}`]=e.props.children,o++);r.push(t),i++}}}return{columns:t,dataSource:r}},_=({children:e})=>{let{columns:t,dataSource:n}=g(e);return(0,a.jsx)(r.Table,{className:`[&_table]:w-full! [&_table]:table!`,columns:t,dataSource:n,pagination:!1,size:`small`,bordered:!0})},{Link:v}=r.Typography;return r=>{let{url:i,requestHeaders:o,className:s,components:c,...l}=r,[u,d]=(0,n.useState)(l.content),f=async e=>{d(await(await fetch(e,{headers:o})).text())};return(0,n.useEffect)(()=>{i&&f(i)},[i]),(0,n.useEffect)(()=>{d(l.content)},[l.content]),(0,a.jsx)(e.XMarkdown,{...l,className:(0,t.default)(`[&_:is(h1,h2,h3,h4,h5,h6,ul,ol,p)]:[all:revert]`,s),content:u,components:{code:m,a:v,table:_,...c}})}});
|