@windrun-huaiin/third-ui 22.0.1 → 23.1.0
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/README.md +152 -189
- package/dist/fuma/server/features/base.d.ts +2 -0
- package/dist/fuma/server/features/base.js +13 -0
- package/dist/fuma/server/features/base.mjs +11 -0
- package/dist/fuma/server/features/code.d.ts +2 -0
- package/dist/fuma/server/features/code.js +65 -0
- package/dist/fuma/server/features/code.mjs +63 -0
- package/dist/fuma/server/features/math.d.ts +2 -0
- package/dist/fuma/server/features/math.js +14 -0
- package/dist/fuma/server/features/math.mjs +12 -0
- package/dist/fuma/server/features/mermaid.d.ts +2 -0
- package/dist/fuma/server/features/mermaid.js +13 -0
- package/dist/fuma/server/features/mermaid.mjs +11 -0
- package/dist/fuma/server/features/type-table.d.ts +2 -0
- package/dist/fuma/server/features/type-table.js +12 -0
- package/dist/fuma/server/features/type-table.mjs +10 -0
- package/dist/fuma/server/features/widgets.d.ts +2 -0
- package/dist/fuma/server/features/widgets.js +26 -0
- package/dist/fuma/server/features/widgets.mjs +24 -0
- package/dist/fuma/server/optional-features.d.ts +6 -8
- package/dist/fuma/server/optional-features.js +13 -107
- package/dist/fuma/server/optional-features.mjs +6 -104
- package/dist/fuma/server/site-mdx-base.d.ts +13 -0
- package/dist/fuma/server/site-mdx-base.js +36 -0
- package/dist/fuma/server/site-mdx-base.mjs +33 -0
- package/dist/fuma/server/site-mdx-components.d.ts +1 -1
- package/dist/fuma/server/site-mdx-components.js +7 -8
- package/dist/fuma/server/site-mdx-components.mjs +8 -9
- package/dist/fuma/server/site-mdx-fallbacks.d.ts +25 -0
- package/dist/fuma/server/site-mdx-fallbacks.js +79 -0
- package/dist/fuma/server/site-mdx-fallbacks.mjs +73 -0
- package/dist/fuma/server/site-mdx-features/code.d.ts +1 -0
- package/dist/fuma/server/site-mdx-features/code.js +7 -0
- package/dist/fuma/server/site-mdx-features/code.mjs +1 -0
- package/dist/fuma/server/site-mdx-features/math.d.ts +1 -0
- package/dist/fuma/server/site-mdx-features/math.js +7 -0
- package/dist/fuma/server/site-mdx-features/math.mjs +1 -0
- package/dist/fuma/server/site-mdx-features/mermaid.d.ts +1 -0
- package/dist/fuma/server/site-mdx-features/mermaid.js +7 -0
- package/dist/fuma/server/site-mdx-features/mermaid.mjs +1 -0
- package/dist/fuma/server/site-mdx-features/type-table.d.ts +1 -0
- package/dist/fuma/server/site-mdx-features/type-table.js +7 -0
- package/dist/fuma/server/site-mdx-features/type-table.mjs +1 -0
- package/dist/fuma/server/site-mdx-presets.d.ts +2 -1
- package/dist/fuma/server/site-mdx-presets.js +22 -13
- package/dist/fuma/server/site-mdx-presets.mjs +22 -12
- package/dist/fuma/share/markdown-component-map.js +43 -29
- package/dist/fuma/share/markdown-component-map.mjs +42 -28
- package/package.json +28 -13
- package/src/fuma/server/features/base.tsx +23 -0
- package/src/fuma/server/features/code.tsx +100 -0
- package/src/fuma/server/features/math.ts +16 -0
- package/src/fuma/server/features/mermaid.tsx +21 -0
- package/src/fuma/server/features/type-table.ts +12 -0
- package/src/fuma/server/features/widgets.tsx +34 -0
- package/src/fuma/server/site-mdx-base.tsx +66 -0
- package/src/fuma/server/site-mdx-fallbacks.tsx +172 -0
- package/src/fuma/server/site-mdx-features/code.ts +1 -0
- package/src/fuma/server/site-mdx-features/math.ts +1 -0
- package/src/fuma/server/site-mdx-features/mermaid.ts +1 -0
- package/src/fuma/server/site-mdx-features/type-table.ts +1 -0
- package/src/fuma/share/markdown-component-map.tsx +5 -4
- package/src/fuma/server/optional-features.tsx +0 -168
- package/src/fuma/server/site-mdx-components.tsx +0 -48
- package/src/fuma/server/site-mdx-presets.ts +0 -80
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createMathMdxComponents } from '../features/math';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createMathMdxComponents } from '../features/math.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createMermaidMdxComponents } from '../features/mermaid';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createMermaidMdxComponents } from '../features/mermaid.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createTypeTableMdxComponents } from '../features/type-table';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createTypeTableMdxComponents } from '../features/type-table.mjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MDXComponents } from 'mdx/types';
|
|
2
2
|
import { SiteX } from '../site-x';
|
|
3
3
|
import type { SiteMdxComponentsOptions } from './site-mdx-components';
|
|
4
|
-
|
|
4
|
+
export type SiteMdxFeature = 'base' | 'code' | 'math' | 'mermaid' | 'type-table';
|
|
5
5
|
export declare const DEFAULT_SITE_MDX_FEATURES: SiteMdxFeature[];
|
|
6
6
|
export declare function createSiteFeatureComponentMap(options: SiteMdxComponentsOptions): {
|
|
7
7
|
base: {
|
|
@@ -192,3 +192,4 @@ export declare function createSiteFeatureComponentMap(options: SiteMdxComponents
|
|
|
192
192
|
'type-table': MDXComponents;
|
|
193
193
|
};
|
|
194
194
|
export declare function composeSiteMdxComponents(features: readonly SiteMdxFeature[], featureMap: Record<SiteMdxFeature, MDXComponents>, additionalComponents?: MDXComponents, components?: MDXComponents): MDXComponents;
|
|
195
|
+
export declare function createComposedSiteMdxComponents(features: readonly SiteMdxFeature[], options: SiteMdxComponentsOptions, additionalComponents?: MDXComponents, components?: MDXComponents): MDXComponents;
|
|
@@ -5,7 +5,12 @@ var tabs = require('fumadocs-ui/components/tabs');
|
|
|
5
5
|
var callout = require('fumadocs-ui/components/callout');
|
|
6
6
|
var files = require('fumadocs-ui/components/files');
|
|
7
7
|
var accordion = require('fumadocs-ui/components/accordion');
|
|
8
|
-
var
|
|
8
|
+
var base = require('./features/base.js');
|
|
9
|
+
var code = require('./features/code.js');
|
|
10
|
+
var math = require('./features/math.js');
|
|
11
|
+
var mermaid = require('./features/mermaid.js');
|
|
12
|
+
var typeTable = require('./features/type-table.js');
|
|
13
|
+
var widgets = require('./features/widgets.js');
|
|
9
14
|
var siteX = require('../site-x.js');
|
|
10
15
|
|
|
11
16
|
const defaultFumaUiComponents = {
|
|
@@ -25,22 +30,26 @@ const DEFAULT_SITE_MDX_FEATURES = [
|
|
|
25
30
|
'mermaid',
|
|
26
31
|
'type-table',
|
|
27
32
|
];
|
|
28
|
-
function
|
|
33
|
+
function createSiteFeatureComponents(feature, options) {
|
|
29
34
|
const { cdnBaseUrl, iconMap = {}, imageFallbackSrc, watermarkEnabled, watermarkText, } = options;
|
|
30
|
-
|
|
31
|
-
base:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
'
|
|
36
|
-
|
|
35
|
+
switch (feature) {
|
|
36
|
+
case 'base':
|
|
37
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultFumaUiComponents), { SiteX: siteX.SiteX }), base.createBaseMdxComponents(imageFallbackSrc)), widgets.createWidgetMdxComponents(cdnBaseUrl, imageFallbackSrc));
|
|
38
|
+
case 'code':
|
|
39
|
+
return code.createCodeMdxComponents(iconMap);
|
|
40
|
+
case 'math':
|
|
41
|
+
return math.createMathMdxComponents();
|
|
42
|
+
case 'mermaid':
|
|
43
|
+
return mermaid.createMermaidMdxComponents(watermarkEnabled, watermarkText);
|
|
44
|
+
case 'type-table':
|
|
45
|
+
return typeTable.createTypeTableMdxComponents();
|
|
46
|
+
}
|
|
37
47
|
}
|
|
38
|
-
function
|
|
48
|
+
function createComposedSiteMdxComponents(features, options, additionalComponents, components) {
|
|
39
49
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultMdxComponents), features.reduce((acc, feature) => {
|
|
40
|
-
return Object.assign(Object.assign({}, acc),
|
|
50
|
+
return Object.assign(Object.assign({}, acc), createSiteFeatureComponents(feature, options));
|
|
41
51
|
}, {})), additionalComponents), components);
|
|
42
52
|
}
|
|
43
53
|
|
|
44
54
|
exports.DEFAULT_SITE_MDX_FEATURES = DEFAULT_SITE_MDX_FEATURES;
|
|
45
|
-
exports.
|
|
46
|
-
exports.createSiteFeatureComponentMap = createSiteFeatureComponentMap;
|
|
55
|
+
exports.createComposedSiteMdxComponents = createComposedSiteMdxComponents;
|
|
@@ -3,7 +3,12 @@ import { Tabs, Tab } from 'fumadocs-ui/components/tabs';
|
|
|
3
3
|
import { Callout } from 'fumadocs-ui/components/callout';
|
|
4
4
|
import { Files, Folder, File } from 'fumadocs-ui/components/files';
|
|
5
5
|
import { Accordions, Accordion } from 'fumadocs-ui/components/accordion';
|
|
6
|
-
import {
|
|
6
|
+
import { createBaseMdxComponents } from './features/base.mjs';
|
|
7
|
+
import { createCodeMdxComponents } from './features/code.mjs';
|
|
8
|
+
import { createMathMdxComponents } from './features/math.mjs';
|
|
9
|
+
import { createMermaidMdxComponents } from './features/mermaid.mjs';
|
|
10
|
+
import { createTypeTableMdxComponents } from './features/type-table.mjs';
|
|
11
|
+
import { createWidgetMdxComponents } from './features/widgets.mjs';
|
|
7
12
|
import { SiteX } from '../site-x.mjs';
|
|
8
13
|
|
|
9
14
|
const defaultFumaUiComponents = {
|
|
@@ -23,20 +28,25 @@ const DEFAULT_SITE_MDX_FEATURES = [
|
|
|
23
28
|
'mermaid',
|
|
24
29
|
'type-table',
|
|
25
30
|
];
|
|
26
|
-
function
|
|
31
|
+
function createSiteFeatureComponents(feature, options) {
|
|
27
32
|
const { cdnBaseUrl, iconMap = {}, imageFallbackSrc, watermarkEnabled, watermarkText, } = options;
|
|
28
|
-
|
|
29
|
-
base:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
'
|
|
34
|
-
|
|
33
|
+
switch (feature) {
|
|
34
|
+
case 'base':
|
|
35
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultFumaUiComponents), { SiteX }), createBaseMdxComponents(imageFallbackSrc)), createWidgetMdxComponents(cdnBaseUrl, imageFallbackSrc));
|
|
36
|
+
case 'code':
|
|
37
|
+
return createCodeMdxComponents(iconMap);
|
|
38
|
+
case 'math':
|
|
39
|
+
return createMathMdxComponents();
|
|
40
|
+
case 'mermaid':
|
|
41
|
+
return createMermaidMdxComponents(watermarkEnabled, watermarkText);
|
|
42
|
+
case 'type-table':
|
|
43
|
+
return createTypeTableMdxComponents();
|
|
44
|
+
}
|
|
35
45
|
}
|
|
36
|
-
function
|
|
46
|
+
function createComposedSiteMdxComponents(features, options, additionalComponents, components) {
|
|
37
47
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, defaultMdxComponents), features.reduce((acc, feature) => {
|
|
38
|
-
return Object.assign(Object.assign({}, acc),
|
|
48
|
+
return Object.assign(Object.assign({}, acc), createSiteFeatureComponents(feature, options));
|
|
39
49
|
}, {})), additionalComponents), components);
|
|
40
50
|
}
|
|
41
51
|
|
|
42
|
-
export { DEFAULT_SITE_MDX_FEATURES,
|
|
52
|
+
export { DEFAULT_SITE_MDX_FEATURES, createComposedSiteMdxComponents };
|
|
@@ -3,77 +3,91 @@
|
|
|
3
3
|
var tslib = require('tslib');
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
var utils = require('@windrun-huaiin/lib/utils');
|
|
6
|
-
var
|
|
7
|
-
var imageZoom = require('../heavy/image-zoom.js');
|
|
8
|
-
require('katex');
|
|
9
|
-
require('@windrun-huaiin/base-ui/icons');
|
|
10
|
-
require('next-themes');
|
|
11
|
-
require('roughjs');
|
|
12
|
-
require('react');
|
|
13
|
-
require('@windrun-huaiin/base-ui/lib');
|
|
6
|
+
var React = require('react');
|
|
14
7
|
|
|
8
|
+
const ImageZoom = React.lazy(() => Promise.resolve().then(function () { return require('../heavy/image-zoom.js'); }).then((mod) => ({ default: mod.ImageZoom })));
|
|
15
9
|
function normalizeMarkdownProps(props) {
|
|
16
10
|
const { class: legacyClassName, className } = props, restProps = tslib.__rest(props, ["class", "className"]);
|
|
17
11
|
return Object.assign(Object.assign({}, restProps), { className: utils.cn(typeof legacyClassName === 'string' ? legacyClassName : undefined, className) });
|
|
18
12
|
}
|
|
19
|
-
const baseMarkdownComponents =
|
|
13
|
+
const baseMarkdownComponents = {
|
|
14
|
+
a: (_a) => {
|
|
20
15
|
var _b, _c;
|
|
21
16
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
22
17
|
return (jsxRuntime.jsx("a", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('underline underline-offset-4 transition hover:opacity-80', normalizeMarkdownProps(props).className, className), target: (_b = props.target) !== null && _b !== void 0 ? _b : '_blank', rel: (_c = props.rel) !== null && _c !== void 0 ? _c : 'noreferrer noopener' })));
|
|
23
|
-
},
|
|
18
|
+
},
|
|
19
|
+
blockquote: (_a) => {
|
|
24
20
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
25
21
|
return (jsxRuntime.jsx("blockquote", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('border-l-2 border-border pl-4 text-muted-foreground', normalizeMarkdownProps(props).className, className) })));
|
|
26
|
-
},
|
|
22
|
+
},
|
|
23
|
+
code: (_a) => {
|
|
27
24
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
28
25
|
return (jsxRuntime.jsx("code", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('rounded-md bg-muted px-1.5 py-0.5 font-mono text-[0.9em]', normalizeMarkdownProps(props).className, className) })));
|
|
29
|
-
},
|
|
26
|
+
},
|
|
27
|
+
h1: (_a) => {
|
|
30
28
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
31
29
|
return (jsxRuntime.jsx("h1", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('text-2xl font-semibold tracking-tight', normalizeMarkdownProps(props).className, className) })));
|
|
32
|
-
},
|
|
30
|
+
},
|
|
31
|
+
h2: (_a) => {
|
|
33
32
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
34
33
|
return (jsxRuntime.jsx("h2", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('text-xl font-semibold tracking-tight', normalizeMarkdownProps(props).className, className) })));
|
|
35
|
-
},
|
|
34
|
+
},
|
|
35
|
+
h3: (_a) => {
|
|
36
36
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
37
37
|
return (jsxRuntime.jsx("h3", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('text-lg font-semibold', normalizeMarkdownProps(props).className, className) })));
|
|
38
|
-
},
|
|
38
|
+
},
|
|
39
|
+
h4: (_a) => {
|
|
39
40
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
40
41
|
return (jsxRuntime.jsx("h4", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('text-base font-semibold', normalizeMarkdownProps(props).className, className) })));
|
|
41
|
-
},
|
|
42
|
+
},
|
|
43
|
+
h5: (_a) => {
|
|
42
44
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
43
45
|
return (jsxRuntime.jsx("h5", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('text-sm font-semibold', normalizeMarkdownProps(props).className, className) })));
|
|
44
|
-
},
|
|
46
|
+
},
|
|
47
|
+
h6: (_a) => {
|
|
45
48
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
46
49
|
return (jsxRuntime.jsx("h6", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('text-sm font-semibold', normalizeMarkdownProps(props).className, className) })));
|
|
47
|
-
},
|
|
50
|
+
},
|
|
51
|
+
hr: (_a) => {
|
|
48
52
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
49
53
|
return (jsxRuntime.jsx("hr", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('border-border', normalizeMarkdownProps(props).className, className) })));
|
|
50
|
-
},
|
|
54
|
+
},
|
|
55
|
+
img: (_a) => {
|
|
51
56
|
var { className, alt, src } = _a, props = tslib.__rest(_a, ["className", "alt", "src"]);
|
|
52
|
-
return (jsxRuntime.jsx(
|
|
53
|
-
},
|
|
57
|
+
return (jsxRuntime.jsx(ImageZoom, Object.assign({}, normalizeMarkdownProps(props), { alt: typeof alt === 'string' ? alt : '', src: typeof src === 'string' ? src : '', className: utils.cn('overflow-hidden rounded-2xl', normalizeMarkdownProps(props).className, className) })));
|
|
58
|
+
},
|
|
59
|
+
li: (_a) => {
|
|
54
60
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
55
61
|
return (jsxRuntime.jsx("li", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('leading-7', normalizeMarkdownProps(props).className, className) })));
|
|
56
|
-
},
|
|
62
|
+
},
|
|
63
|
+
ol: (_a) => {
|
|
57
64
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
58
65
|
return (jsxRuntime.jsx("ol", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('list-decimal space-y-2 pl-6', normalizeMarkdownProps(props).className, className) })));
|
|
59
|
-
},
|
|
66
|
+
},
|
|
67
|
+
p: (_a) => {
|
|
60
68
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
61
69
|
return (jsxRuntime.jsx("p", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('leading-7', normalizeMarkdownProps(props).className, className) })));
|
|
62
|
-
},
|
|
70
|
+
},
|
|
71
|
+
pre: (_a) => {
|
|
63
72
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
64
73
|
return (jsxRuntime.jsx("pre", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('overflow-x-auto rounded-2xl border border-border bg-muted px-4 py-3 text-sm', normalizeMarkdownProps(props).className, className) })));
|
|
65
|
-
},
|
|
74
|
+
},
|
|
75
|
+
table: (_a) => {
|
|
66
76
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
67
77
|
return (jsxRuntime.jsx("div", { className: "overflow-x-auto", children: jsxRuntime.jsx("table", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('w-full border-collapse text-sm', normalizeMarkdownProps(props).className, className) })) }));
|
|
68
|
-
},
|
|
78
|
+
},
|
|
79
|
+
td: (_a) => {
|
|
69
80
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
70
81
|
return (jsxRuntime.jsx("td", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('border border-border px-3 py-2 align-top', normalizeMarkdownProps(props).className, className) })));
|
|
71
|
-
},
|
|
82
|
+
},
|
|
83
|
+
th: (_a) => {
|
|
72
84
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
73
85
|
return (jsxRuntime.jsx("th", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('border border-border px-3 py-2 text-left font-medium', normalizeMarkdownProps(props).className, className) })));
|
|
74
|
-
},
|
|
86
|
+
},
|
|
87
|
+
ul: (_a) => {
|
|
75
88
|
var { className } = _a, props = tslib.__rest(_a, ["className"]);
|
|
76
89
|
return (jsxRuntime.jsx("ul", Object.assign({}, normalizeMarkdownProps(props), { className: utils.cn('list-disc space-y-2 pl-6', normalizeMarkdownProps(props).className, className) })));
|
|
77
|
-
}
|
|
90
|
+
},
|
|
91
|
+
};
|
|
78
92
|
|
|
79
93
|
exports.baseMarkdownComponents = baseMarkdownComponents;
|
|
@@ -1,77 +1,91 @@
|
|
|
1
1
|
import { __rest } from 'tslib';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { cn } from '@windrun-huaiin/lib/utils';
|
|
4
|
-
import
|
|
5
|
-
import { ImageZoom } from '../heavy/image-zoom.mjs';
|
|
6
|
-
import 'katex';
|
|
7
|
-
import '@windrun-huaiin/base-ui/icons';
|
|
8
|
-
import 'next-themes';
|
|
9
|
-
import 'roughjs';
|
|
10
|
-
import 'react';
|
|
11
|
-
import '@windrun-huaiin/base-ui/lib';
|
|
4
|
+
import { lazy } from 'react';
|
|
12
5
|
|
|
6
|
+
const ImageZoom = lazy(() => import('../heavy/image-zoom.mjs').then((mod) => ({ default: mod.ImageZoom })));
|
|
13
7
|
function normalizeMarkdownProps(props) {
|
|
14
8
|
const { class: legacyClassName, className } = props, restProps = __rest(props, ["class", "className"]);
|
|
15
9
|
return Object.assign(Object.assign({}, restProps), { className: cn(typeof legacyClassName === 'string' ? legacyClassName : undefined, className) });
|
|
16
10
|
}
|
|
17
|
-
const baseMarkdownComponents =
|
|
11
|
+
const baseMarkdownComponents = {
|
|
12
|
+
a: (_a) => {
|
|
18
13
|
var _b, _c;
|
|
19
14
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
20
15
|
return (jsx("a", Object.assign({}, normalizeMarkdownProps(props), { className: cn('underline underline-offset-4 transition hover:opacity-80', normalizeMarkdownProps(props).className, className), target: (_b = props.target) !== null && _b !== void 0 ? _b : '_blank', rel: (_c = props.rel) !== null && _c !== void 0 ? _c : 'noreferrer noopener' })));
|
|
21
|
-
},
|
|
16
|
+
},
|
|
17
|
+
blockquote: (_a) => {
|
|
22
18
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
23
19
|
return (jsx("blockquote", Object.assign({}, normalizeMarkdownProps(props), { className: cn('border-l-2 border-border pl-4 text-muted-foreground', normalizeMarkdownProps(props).className, className) })));
|
|
24
|
-
},
|
|
20
|
+
},
|
|
21
|
+
code: (_a) => {
|
|
25
22
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
26
23
|
return (jsx("code", Object.assign({}, normalizeMarkdownProps(props), { className: cn('rounded-md bg-muted px-1.5 py-0.5 font-mono text-[0.9em]', normalizeMarkdownProps(props).className, className) })));
|
|
27
|
-
},
|
|
24
|
+
},
|
|
25
|
+
h1: (_a) => {
|
|
28
26
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
29
27
|
return (jsx("h1", Object.assign({}, normalizeMarkdownProps(props), { className: cn('text-2xl font-semibold tracking-tight', normalizeMarkdownProps(props).className, className) })));
|
|
30
|
-
},
|
|
28
|
+
},
|
|
29
|
+
h2: (_a) => {
|
|
31
30
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
32
31
|
return (jsx("h2", Object.assign({}, normalizeMarkdownProps(props), { className: cn('text-xl font-semibold tracking-tight', normalizeMarkdownProps(props).className, className) })));
|
|
33
|
-
},
|
|
32
|
+
},
|
|
33
|
+
h3: (_a) => {
|
|
34
34
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
35
35
|
return (jsx("h3", Object.assign({}, normalizeMarkdownProps(props), { className: cn('text-lg font-semibold', normalizeMarkdownProps(props).className, className) })));
|
|
36
|
-
},
|
|
36
|
+
},
|
|
37
|
+
h4: (_a) => {
|
|
37
38
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
38
39
|
return (jsx("h4", Object.assign({}, normalizeMarkdownProps(props), { className: cn('text-base font-semibold', normalizeMarkdownProps(props).className, className) })));
|
|
39
|
-
},
|
|
40
|
+
},
|
|
41
|
+
h5: (_a) => {
|
|
40
42
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
41
43
|
return (jsx("h5", Object.assign({}, normalizeMarkdownProps(props), { className: cn('text-sm font-semibold', normalizeMarkdownProps(props).className, className) })));
|
|
42
|
-
},
|
|
44
|
+
},
|
|
45
|
+
h6: (_a) => {
|
|
43
46
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
44
47
|
return (jsx("h6", Object.assign({}, normalizeMarkdownProps(props), { className: cn('text-sm font-semibold', normalizeMarkdownProps(props).className, className) })));
|
|
45
|
-
},
|
|
48
|
+
},
|
|
49
|
+
hr: (_a) => {
|
|
46
50
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
47
51
|
return (jsx("hr", Object.assign({}, normalizeMarkdownProps(props), { className: cn('border-border', normalizeMarkdownProps(props).className, className) })));
|
|
48
|
-
},
|
|
52
|
+
},
|
|
53
|
+
img: (_a) => {
|
|
49
54
|
var { className, alt, src } = _a, props = __rest(_a, ["className", "alt", "src"]);
|
|
50
55
|
return (jsx(ImageZoom, Object.assign({}, normalizeMarkdownProps(props), { alt: typeof alt === 'string' ? alt : '', src: typeof src === 'string' ? src : '', className: cn('overflow-hidden rounded-2xl', normalizeMarkdownProps(props).className, className) })));
|
|
51
|
-
},
|
|
56
|
+
},
|
|
57
|
+
li: (_a) => {
|
|
52
58
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
53
59
|
return (jsx("li", Object.assign({}, normalizeMarkdownProps(props), { className: cn('leading-7', normalizeMarkdownProps(props).className, className) })));
|
|
54
|
-
},
|
|
60
|
+
},
|
|
61
|
+
ol: (_a) => {
|
|
55
62
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
56
63
|
return (jsx("ol", Object.assign({}, normalizeMarkdownProps(props), { className: cn('list-decimal space-y-2 pl-6', normalizeMarkdownProps(props).className, className) })));
|
|
57
|
-
},
|
|
64
|
+
},
|
|
65
|
+
p: (_a) => {
|
|
58
66
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
59
67
|
return (jsx("p", Object.assign({}, normalizeMarkdownProps(props), { className: cn('leading-7', normalizeMarkdownProps(props).className, className) })));
|
|
60
|
-
},
|
|
68
|
+
},
|
|
69
|
+
pre: (_a) => {
|
|
61
70
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
62
71
|
return (jsx("pre", Object.assign({}, normalizeMarkdownProps(props), { className: cn('overflow-x-auto rounded-2xl border border-border bg-muted px-4 py-3 text-sm', normalizeMarkdownProps(props).className, className) })));
|
|
63
|
-
},
|
|
72
|
+
},
|
|
73
|
+
table: (_a) => {
|
|
64
74
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
65
75
|
return (jsx("div", { className: "overflow-x-auto", children: jsx("table", Object.assign({}, normalizeMarkdownProps(props), { className: cn('w-full border-collapse text-sm', normalizeMarkdownProps(props).className, className) })) }));
|
|
66
|
-
},
|
|
76
|
+
},
|
|
77
|
+
td: (_a) => {
|
|
67
78
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
68
79
|
return (jsx("td", Object.assign({}, normalizeMarkdownProps(props), { className: cn('border border-border px-3 py-2 align-top', normalizeMarkdownProps(props).className, className) })));
|
|
69
|
-
},
|
|
80
|
+
},
|
|
81
|
+
th: (_a) => {
|
|
70
82
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
71
83
|
return (jsx("th", Object.assign({}, normalizeMarkdownProps(props), { className: cn('border border-border px-3 py-2 text-left font-medium', normalizeMarkdownProps(props).className, className) })));
|
|
72
|
-
},
|
|
84
|
+
},
|
|
85
|
+
ul: (_a) => {
|
|
73
86
|
var { className } = _a, props = __rest(_a, ["className"]);
|
|
74
87
|
return (jsx("ul", Object.assign({}, normalizeMarkdownProps(props), { className: cn('list-disc space-y-2 pl-6', normalizeMarkdownProps(props).className, className) })));
|
|
75
|
-
}
|
|
88
|
+
},
|
|
89
|
+
};
|
|
76
90
|
|
|
77
91
|
export { baseMarkdownComponents };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@windrun-huaiin/third-ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "23.1.0",
|
|
4
4
|
"description": "Third-party integrated UI components for windrun-huaiin projects",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./clerk": {
|
|
@@ -48,10 +48,30 @@
|
|
|
48
48
|
"import": "./dist/fuma/server.mjs",
|
|
49
49
|
"require": "./dist/fuma/server.js"
|
|
50
50
|
},
|
|
51
|
-
"./fuma/server/site-mdx
|
|
52
|
-
"types": "./dist/fuma/server/site-mdx-
|
|
53
|
-
"import": "./dist/fuma/server/site-mdx-
|
|
54
|
-
"require": "./dist/fuma/server/site-mdx-
|
|
51
|
+
"./fuma/server/site-mdx/base": {
|
|
52
|
+
"types": "./dist/fuma/server/site-mdx-base.d.ts",
|
|
53
|
+
"import": "./dist/fuma/server/site-mdx-base.mjs",
|
|
54
|
+
"require": "./dist/fuma/server/site-mdx-base.js"
|
|
55
|
+
},
|
|
56
|
+
"./fuma/server/site-mdx/features/code": {
|
|
57
|
+
"types": "./dist/fuma/server/site-mdx-features/code.d.ts",
|
|
58
|
+
"import": "./dist/fuma/server/site-mdx-features/code.mjs",
|
|
59
|
+
"require": "./dist/fuma/server/site-mdx-features/code.js"
|
|
60
|
+
},
|
|
61
|
+
"./fuma/server/site-mdx/features/math": {
|
|
62
|
+
"types": "./dist/fuma/server/site-mdx-features/math.d.ts",
|
|
63
|
+
"import": "./dist/fuma/server/site-mdx-features/math.mjs",
|
|
64
|
+
"require": "./dist/fuma/server/site-mdx-features/math.js"
|
|
65
|
+
},
|
|
66
|
+
"./fuma/server/site-mdx/features/mermaid": {
|
|
67
|
+
"types": "./dist/fuma/server/site-mdx-features/mermaid.d.ts",
|
|
68
|
+
"import": "./dist/fuma/server/site-mdx-features/mermaid.mjs",
|
|
69
|
+
"require": "./dist/fuma/server/site-mdx-features/mermaid.js"
|
|
70
|
+
},
|
|
71
|
+
"./fuma/server/site-mdx/features/type-table": {
|
|
72
|
+
"types": "./dist/fuma/server/site-mdx-features/type-table.d.ts",
|
|
73
|
+
"import": "./dist/fuma/server/site-mdx-features/type-table.mjs",
|
|
74
|
+
"require": "./dist/fuma/server/site-mdx-features/type-table.js"
|
|
55
75
|
},
|
|
56
76
|
"./fuma/share": {
|
|
57
77
|
"types": "./dist/fuma/share/index.d.ts",
|
|
@@ -68,11 +88,6 @@
|
|
|
68
88
|
"import": "./dist/fuma/mdx/index.mjs",
|
|
69
89
|
"require": "./dist/fuma/mdx/index.js"
|
|
70
90
|
},
|
|
71
|
-
"./fuma/server/optional-features": {
|
|
72
|
-
"types": "./dist/fuma/server/optional-features.d.ts",
|
|
73
|
-
"import": "./dist/fuma/server/optional-features.mjs",
|
|
74
|
-
"require": "./dist/fuma/server/optional-features.js"
|
|
75
|
-
},
|
|
76
91
|
"./fuma/base": {
|
|
77
92
|
"types": "./dist/fuma/base/index.d.ts",
|
|
78
93
|
"import": "./dist/fuma/base/index.mjs",
|
|
@@ -122,9 +137,9 @@
|
|
|
122
137
|
"tslib": "^2.8.1",
|
|
123
138
|
"unified": "^11.0.5",
|
|
124
139
|
"zod": "^4.3.6",
|
|
125
|
-
"@windrun-huaiin/base-ui": "^
|
|
126
|
-
"@windrun-huaiin/
|
|
127
|
-
"@windrun-huaiin/
|
|
140
|
+
"@windrun-huaiin/base-ui": "^23.1.0",
|
|
141
|
+
"@windrun-huaiin/contracts": "^23.1.0",
|
|
142
|
+
"@windrun-huaiin/lib": "^23.1.0"
|
|
128
143
|
},
|
|
129
144
|
"peerDependencies": {
|
|
130
145
|
"clsx": "^2.1.1",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { MDXComponents } from 'mdx/types';
|
|
2
|
+
import { baseMarkdownComponents } from '../../share/markdown-component-map';
|
|
3
|
+
import { lazy } from 'react';
|
|
4
|
+
import { createMissingMdxFeatureComponents } from '../site-mdx-fallbacks';
|
|
5
|
+
|
|
6
|
+
const ImageZoom = lazy(() =>
|
|
7
|
+
import('../../heavy/image-zoom').then((mod) => ({ default: mod.ImageZoom })),
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
export function createBaseMdxComponents(
|
|
11
|
+
imageFallbackSrc?: string,
|
|
12
|
+
): MDXComponents {
|
|
13
|
+
return {
|
|
14
|
+
...baseMarkdownComponents,
|
|
15
|
+
...createMissingMdxFeatureComponents(),
|
|
16
|
+
img: (props) => (
|
|
17
|
+
<ImageZoom
|
|
18
|
+
{...(props as any)}
|
|
19
|
+
fallbackSrc={imageFallbackSrc}
|
|
20
|
+
/>
|
|
21
|
+
),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import type { MDXComponents, MDXProps } from 'mdx/types';
|
|
2
|
+
import { lazy, type ReactNode } from 'react';
|
|
3
|
+
import {
|
|
4
|
+
CSSIcon,
|
|
5
|
+
CSVIcon,
|
|
6
|
+
DiffIcon,
|
|
7
|
+
HtmlIcon,
|
|
8
|
+
HttpIcon,
|
|
9
|
+
JavaIcon,
|
|
10
|
+
JsonIcon,
|
|
11
|
+
LogIcon,
|
|
12
|
+
MDXIcon,
|
|
13
|
+
RegexIcon,
|
|
14
|
+
SQLIcon,
|
|
15
|
+
SchemeIcon,
|
|
16
|
+
SquareDashedBottomCodeIcon,
|
|
17
|
+
TxtIcon,
|
|
18
|
+
XMLIcon,
|
|
19
|
+
YamlIcon,
|
|
20
|
+
} from '@windrun-huaiin/base-ui/icons';
|
|
21
|
+
|
|
22
|
+
const CodeBlock = lazy(() =>
|
|
23
|
+
import('fumadocs-ui/components/codeblock').then((mod) => ({ default: mod.CodeBlock })),
|
|
24
|
+
);
|
|
25
|
+
const Pre = lazy(() =>
|
|
26
|
+
import('fumadocs-ui/components/codeblock').then((mod) => ({ default: mod.Pre })),
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const defaultCodeLanguageIconMap: Record<string, ReactNode> = {
|
|
30
|
+
css: <CSSIcon />,
|
|
31
|
+
csv: <CSVIcon />,
|
|
32
|
+
diff: <DiffIcon />,
|
|
33
|
+
html: <HtmlIcon />,
|
|
34
|
+
http: <HttpIcon />,
|
|
35
|
+
java: <JavaIcon />,
|
|
36
|
+
json: <JsonIcon />,
|
|
37
|
+
jsonc: <SquareDashedBottomCodeIcon />,
|
|
38
|
+
log: <LogIcon />,
|
|
39
|
+
mdx: <MDXIcon />,
|
|
40
|
+
plaintext: <TxtIcon />,
|
|
41
|
+
regex: <RegexIcon />,
|
|
42
|
+
scheme: <SchemeIcon />,
|
|
43
|
+
sql: <SQLIcon />,
|
|
44
|
+
text: <TxtIcon />,
|
|
45
|
+
txt: <TxtIcon />,
|
|
46
|
+
xml: <XMLIcon />,
|
|
47
|
+
yaml: <YamlIcon />,
|
|
48
|
+
yml: <YamlIcon />,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
function tryToMatchIcon(
|
|
52
|
+
props: Readonly<MDXProps & { 'data-language'?: string; title?: string }>,
|
|
53
|
+
iconMap: Record<string, ReactNode>,
|
|
54
|
+
): ReactNode | undefined {
|
|
55
|
+
let lang: string | undefined;
|
|
56
|
+
|
|
57
|
+
const dataLanguage = props['data-language'] as string | undefined;
|
|
58
|
+
|
|
59
|
+
if (dataLanguage && dataLanguage.trim() !== '') {
|
|
60
|
+
lang = dataLanguage.trim().toLowerCase();
|
|
61
|
+
} else {
|
|
62
|
+
const title = props.title as string | undefined;
|
|
63
|
+
if (title) {
|
|
64
|
+
const titleParts = title.split('.');
|
|
65
|
+
if (titleParts.length > 1 && titleParts[0] !== '') {
|
|
66
|
+
const extension = titleParts.pop()?.toLowerCase();
|
|
67
|
+
if (extension) {
|
|
68
|
+
lang = extension;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (lang && iconMap[lang]) {
|
|
75
|
+
return iconMap[lang];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function createCodeMdxComponents(): MDXComponents {
|
|
82
|
+
return {
|
|
83
|
+
pre: (props) => {
|
|
84
|
+
const customIcon = tryToMatchIcon(
|
|
85
|
+
props as MDXProps & { 'data-language'?: string; title?: string },
|
|
86
|
+
defaultCodeLanguageIconMap,
|
|
87
|
+
);
|
|
88
|
+
return (
|
|
89
|
+
<CodeBlock
|
|
90
|
+
{...props}
|
|
91
|
+
{...(customIcon && { icon: customIcon })}
|
|
92
|
+
>
|
|
93
|
+
<Pre>{props.children}</Pre>
|
|
94
|
+
</CodeBlock>
|
|
95
|
+
);
|
|
96
|
+
},
|
|
97
|
+
CodeBlock,
|
|
98
|
+
Pre,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { MDXComponents } from 'mdx/types';
|
|
2
|
+
import { lazy } from 'react';
|
|
3
|
+
|
|
4
|
+
const MathBlock = lazy(() =>
|
|
5
|
+
import('../../heavy/math').then((mod) => ({ default: mod.MathBlock })),
|
|
6
|
+
);
|
|
7
|
+
const InlineMath = lazy(() =>
|
|
8
|
+
import('../../heavy/math').then((mod) => ({ default: mod.InlineMath })),
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
export function createMathMdxComponents(): MDXComponents {
|
|
12
|
+
return {
|
|
13
|
+
MathBlock,
|
|
14
|
+
InlineMath,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { MDXComponents } from 'mdx/types';
|
|
2
|
+
import { lazy } from 'react';
|
|
3
|
+
|
|
4
|
+
const Mermaid = lazy(() =>
|
|
5
|
+
import('../../heavy/mermaid').then((mod) => ({ default: mod.Mermaid })),
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
export function createMermaidMdxComponents(
|
|
9
|
+
watermarkEnabled?: boolean,
|
|
10
|
+
watermarkText?: string,
|
|
11
|
+
): MDXComponents {
|
|
12
|
+
return {
|
|
13
|
+
Mermaid: (props) => (
|
|
14
|
+
<Mermaid
|
|
15
|
+
{...props}
|
|
16
|
+
watermarkEnabled={watermarkEnabled}
|
|
17
|
+
watermarkText={watermarkText}
|
|
18
|
+
/>
|
|
19
|
+
),
|
|
20
|
+
};
|
|
21
|
+
}
|