@infinilabs/markdown 0.0.1 → 0.0.3

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 CHANGED
@@ -1,85 +1,82 @@
1
- import { jsx as u } from "react/jsx-runtime";
2
- import { XMarkdown as b } from "@ant-design/x-markdown";
3
- import g from "clsx";
4
- import { Children as p, isValidElement as f, useState as w, useEffect as x } from "react";
5
- import { Typography as A, Table as T } from "antd";
6
- import { Mermaid as _, CodeHighlighter as C } from "@ant-design/x";
7
- const { Text: k } = A, N = (t) => {
8
- const { className: o, children: r } = t, n = o?.match(/language-(\w+)/)?.[1] ?? "";
9
- return typeof r != "string" ? null : n === "mermaid" ? /* @__PURE__ */ u(_, { children: r }) : n ? /* @__PURE__ */ u(C, { lang: n, children: r }) : /* @__PURE__ */ u(k, { code: !0, children: r });
10
- }, m = (t) => typeof t == "string" || typeof t == "number" ? String(t) : f(t) ? m(t.props.children) : Array.isArray(t) ? t.map(m).join("") : "", $ = (t) => {
11
- const o = [], r = [], n = p.toArray(t);
12
- for (const e of n) {
13
- if (!f(e)) continue;
14
- const d = e.type;
15
- if (d === "thead") {
16
- const a = p.toArray(e.props.children);
17
- for (const c of a) {
18
- if (!f(c)) continue;
19
- const i = p.toArray(c.props.children);
20
- let s = 0;
21
- for (const l of i) {
22
- if (!f(l)) continue;
23
- const h = m(l.props.children);
24
- o.push({
25
- title: h,
26
- dataIndex: `col_${s}`,
27
- key: `col_${s}`
28
- }), s++;
29
- }
30
- }
31
- }
32
- if (d === "tbody") {
33
- const a = p.toArray(e.props.children);
34
- let c = 0;
35
- for (const i of a) {
36
- if (!f(i)) continue;
37
- const s = { key: `row_${c}` }, l = p.toArray(i.props.children);
38
- let h = 0;
39
- for (const y of l)
40
- f(y) && (s[`col_${h}`] = y.props.children, h++);
41
- r.push(s), c++;
42
- }
43
- }
44
- }
45
- return { columns: o, dataSource: r };
46
- }, S = ({ children: t }) => {
47
- const { columns: o, dataSource: r } = $(t);
48
- return /* @__PURE__ */ u(
49
- T,
50
- {
51
- className: "[&_table]:w-full! [&_table]:table!",
52
- columns: o,
53
- dataSource: r,
54
- pagination: !1,
55
- size: "small",
56
- bordered: !0
57
- }
58
- );
59
- }, { Link: I } = A, L = (t) => {
60
- const { url: o, className: r, components: n, ...e } = t, [d, a] = w(e.content), c = async (i) => {
61
- const l = await (await fetch(i)).text();
62
- a(l);
63
- };
64
- return x(() => {
65
- o && c(o);
66
- }, [o]), x(() => {
67
- a(e.content);
68
- }, [e.content]), /* @__PURE__ */ u(
69
- b,
70
- {
71
- ...e,
72
- className: g("[&_h1,h2,h3,h4,h5,h6,ul,ol,p]:[all:revert]", r),
73
- content: d,
74
- components: {
75
- code: N,
76
- a: I,
77
- table: S,
78
- ...n
79
- }
80
- }
81
- );
82
- };
83
- export {
84
- 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: s, children: c } = e, l = s?.match(/language-(\w+)/)?.[1] ?? "";
10
+ return typeof c == "string" ? l === "mermaid" ? /* @__PURE__ */ jsx(Mermaid, { children: c }) : l ? /* @__PURE__ */ jsx(CodeHighlighter, {
11
+ lang: l,
12
+ children: c
13
+ }) : /* @__PURE__ */ jsx(Text, {
14
+ code: !0,
15
+ children: c
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 s = [], u = [], d = Children.toArray(e);
19
+ for (let e of d) {
20
+ if (!isValidElement(e)) continue;
21
+ let d = e.type;
22
+ if (d === "thead") {
23
+ let u = Children.toArray(e.props.children);
24
+ for (let e of u) {
25
+ if (!isValidElement(e)) continue;
26
+ let u = Children.toArray(e.props.children), d = 0;
27
+ for (let e of u) {
28
+ if (!isValidElement(e)) continue;
29
+ let c = extractText(e.props.children);
30
+ s.push({
31
+ title: c,
32
+ dataIndex: `col_${d}`,
33
+ key: `col_${d}`
34
+ }), d++;
35
+ }
36
+ }
37
+ }
38
+ if (d === "tbody") {
39
+ let s = Children.toArray(e.props.children), d = 0;
40
+ for (let e of s) {
41
+ if (!isValidElement(e)) continue;
42
+ let s = { key: `row_${d}` }, f = Children.toArray(e.props.children), p = 0;
43
+ for (let e of f) isValidElement(e) && (s[`col_${p}`] = e.props.children, p++);
44
+ u.push(s), d++;
45
+ }
46
+ }
47
+ }
48
+ return {
49
+ columns: s,
50
+ dataSource: u
51
+ };
52
+ }, Table_default = ({ children: e }) => {
53
+ let { columns: s, dataSource: c } = parseTableChildren(e);
54
+ return /* @__PURE__ */ jsx(Table, {
55
+ className: "[&_table]:w-full! [&_table]:table!",
56
+ columns: s,
57
+ dataSource: c,
58
+ pagination: !1,
59
+ size: "small",
60
+ bordered: !0
61
+ });
62
+ }, { Link } = Typography, components_default = (c) => {
63
+ let { url: l, className: f, components: p, ...m } = c, [h, g] = useState(m.content), _ = async (e) => {
64
+ g(await (await fetch(e)).text());
65
+ };
66
+ return useEffect(() => {
67
+ l && _(l);
68
+ }, [l]), 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
+ });
85
81
  };
82
+ export { components_default as default };
@@ -1 +1,2 @@
1
- (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:o,children:r}=n,i=o?.match(/language-(\w+)/)?.[1]??"";return typeof r!="string"?null:i==="mermaid"?e.jsx(x.Mermaid,{children:r}):i?e.jsx(x.CodeHighlighter,{lang:i,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 o=[],r=[],i=t.Children.toArray(n);for(const s of i){if(!t.isValidElement(s))continue;const p=s.type;if(p==="thead"){const l=t.Children.toArray(s.props.children);for(const c of l){if(!t.isValidElement(c))continue;const d=t.Children.toArray(c.props.children);let a=0;for(const u of d){if(!t.isValidElement(u))continue;const h=y(u.props.children);o.push({title:h,dataIndex:`col_${a}`,key:`col_${a}`}),a++}}}if(p==="tbody"){const l=t.Children.toArray(s.props.children);let c=0;for(const d of l){if(!t.isValidElement(d))continue;const a={key:`row_${c}`},u=t.Children.toArray(d.props.children);let h=0;for(const w of u)t.isValidElement(w)&&(a[`col_${h}`]=w.props.children,h++);r.push(a),c++}}}return{columns:o,dataSource:r}},T=({children:n})=>{const{columns:o,dataSource:r}=C(n);return e.jsx(m.Table,{className:"[&_table]:w-full! [&_table]:table!",columns:o,dataSource:r,pagination:!1,size:"small",bordered:!0})},{Link:E}=m.Typography;return n=>{const{url:o,className:r,components:i,...s}=n,[p,l]=t.useState(s.content),c=async d=>{const u=await(await fetch(d)).text();l(u)};return t.useEffect(()=>{o&&c(o)},[o]),t.useEffect(()=>{l(s.content)},[s.content]),e.jsx(f.XMarkdown,{...s,className:A("[&_h1,h2,h3,h4,h5,h6,ul,ol,p]:[all:revert]",r),content:p,components:{code:k,a:E,table:T,...i}})}}));
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,className:o,components:s,...c}=r,[l,u]=(0,n.useState)(c.content),d=async e=>{u(await(await fetch(e)).text())};return(0,n.useEffect)(()=>{i&&d(i)},[i]),(0,n.useEffect)(()=>{u(c.content)},[c.content]),(0,a.jsx)(e.XMarkdown,{...c,className:(0,t.default)(`[&_:is(h1,h2,h3,h4,h5,h6,ul,ol,p)]:[all:revert]`,o),content:l,components:{code:m,a:v,table:_,...s}})}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infinilabs/markdown",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "files": [
@@ -45,5 +45,9 @@
45
45
  "vite": "^7.2.4",
46
46
  "vite-plugin-css-injected-by-js": "^3.5.2",
47
47
  "vite-plugin-dts": "^4.5.4"
48
+ },
49
+ "repository": {
50
+ "type": "git",
51
+ "url": "https://github.com/infinilabs/ci"
48
52
  }
49
53
  }