@lobehub/ui 1.149.0 → 1.149.2
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/es/Markdown/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { AnchorProps } from 'antd';
|
|
2
2
|
import { CSSProperties } from 'react';
|
|
3
|
+
import type { Components } from 'react-markdown/lib/ast-to-react';
|
|
4
|
+
import type { Pluggable } from 'unified';
|
|
3
5
|
import { type HighlighterProps } from "../Highlighter";
|
|
4
6
|
import { type MermaidProps } from "../Mermaid";
|
|
5
7
|
import { type ImageProps } from "../mdx/Image";
|
|
@@ -19,11 +21,14 @@ export interface MarkdownProps extends TypographyProps {
|
|
|
19
21
|
pre?: Partial<PreProps>;
|
|
20
22
|
video?: Partial<VideoProps>;
|
|
21
23
|
};
|
|
24
|
+
components?: Components;
|
|
22
25
|
enableImageGallery?: boolean;
|
|
23
26
|
enableLatex?: boolean;
|
|
24
27
|
enableMermaid?: boolean;
|
|
25
28
|
fullFeaturedCodeBlock?: boolean;
|
|
26
29
|
onDoubleClick?: () => void;
|
|
30
|
+
rehypePlugins?: Pluggable[];
|
|
31
|
+
remarkPlugins?: Pluggable[];
|
|
27
32
|
style?: CSSProperties;
|
|
28
33
|
variant?: 'normal' | 'chat';
|
|
29
34
|
}
|
package/es/Markdown/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
4
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
5
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
-
var _excluded = ["children", "className", "style", "fullFeaturedCodeBlock", "onDoubleClick", "enableLatex", "enableMermaid", "enableImageGallery", "componentProps", "allowHtml", "fontSize", "headerMultiple", "marginMultiple", "variant", "lineHeight"];
|
|
6
|
+
var _excluded = ["children", "className", "style", "fullFeaturedCodeBlock", "onDoubleClick", "enableLatex", "enableMermaid", "enableImageGallery", "componentProps", "allowHtml", "fontSize", "headerMultiple", "marginMultiple", "variant", "lineHeight", "rehypePlugins", "remarkPlugins", "components"];
|
|
6
7
|
import { memo, useMemo } from 'react';
|
|
7
8
|
import ReactMarkdown from 'react-markdown';
|
|
8
9
|
import rehypeKatex from 'rehype-katex';
|
|
@@ -39,6 +40,12 @@ var Markdown = /*#__PURE__*/memo(function (_ref) {
|
|
|
39
40
|
_ref$variant = _ref.variant,
|
|
40
41
|
variant = _ref$variant === void 0 ? 'normal' : _ref$variant,
|
|
41
42
|
lineHeight = _ref.lineHeight,
|
|
43
|
+
_ref$rehypePlugins = _ref.rehypePlugins,
|
|
44
|
+
rehypePlugins = _ref$rehypePlugins === void 0 ? [] : _ref$rehypePlugins,
|
|
45
|
+
_ref$remarkPlugins = _ref.remarkPlugins,
|
|
46
|
+
remarkPlugins = _ref$remarkPlugins === void 0 ? [] : _ref$remarkPlugins,
|
|
47
|
+
_ref$components = _ref.components,
|
|
48
|
+
components = _ref$components === void 0 ? {} : _ref$components,
|
|
42
49
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
43
50
|
var _useStyles = useStyles({
|
|
44
51
|
fontSize: fontSize,
|
|
@@ -59,7 +66,7 @@ var Markdown = /*#__PURE__*/memo(function (_ref) {
|
|
|
59
66
|
if (!enableLatex) return fixMarkdownBold(children);
|
|
60
67
|
return fixMarkdownBold(escapeMhchem(escapeBrackets(children)));
|
|
61
68
|
}, [children, enableLatex]);
|
|
62
|
-
var
|
|
69
|
+
var componentsCache = useMemo(function () {
|
|
63
70
|
return {
|
|
64
71
|
a: function a(props) {
|
|
65
72
|
return /*#__PURE__*/_jsx(Link, _objectSpread(_objectSpread({}, props), componentProps === null || componentProps === void 0 ? void 0 : componentProps.a));
|
|
@@ -89,12 +96,12 @@ var Markdown = /*#__PURE__*/memo(function (_ref) {
|
|
|
89
96
|
}
|
|
90
97
|
};
|
|
91
98
|
}, [componentProps, enableImageGallery, enableMermaid, fullFeaturedCodeBlock]);
|
|
92
|
-
var
|
|
99
|
+
var rehypePluginsCache = useMemo(function () {
|
|
93
100
|
return [allowHtml && rehypeRaw, enableLatex && rehypeKatex].filter(Boolean);
|
|
94
|
-
}, [allowHtml]);
|
|
95
|
-
var
|
|
101
|
+
}, [allowHtml, enableLatex]);
|
|
102
|
+
var remarkPluginsCache = useMemo(function () {
|
|
96
103
|
return [remarkGfm, enableLatex && remarkMath, isChatMode && remarkBreaks].filter(Boolean);
|
|
97
|
-
}, [isChatMode]);
|
|
104
|
+
}, [isChatMode, enableLatex]);
|
|
98
105
|
return /*#__PURE__*/_jsx("article", {
|
|
99
106
|
className: cx(styles.root, className),
|
|
100
107
|
"data-code-type": "markdown",
|
|
@@ -104,9 +111,9 @@ var Markdown = /*#__PURE__*/memo(function (_ref) {
|
|
|
104
111
|
enable: enableImageGallery,
|
|
105
112
|
children: /*#__PURE__*/_jsx(ReactMarkdown, _objectSpread(_objectSpread({
|
|
106
113
|
className: cx(mdStyles.__root, mdStyles.a, mdStyles.blockquote, mdStyles.code, mdStyles.details, mdStyles.header, mdStyles.hr, mdStyles.img, mdStyles.kbd, mdStyles.list, mdStyles.p, mdStyles.pre, mdStyles.strong, mdStyles.table, mdStyles.video, isChatMode && styles.chat),
|
|
107
|
-
components: components,
|
|
108
|
-
rehypePlugins: rehypePlugins,
|
|
109
|
-
remarkPlugins: remarkPlugins
|
|
114
|
+
components: _objectSpread(_objectSpread({}, componentsCache), components),
|
|
115
|
+
rehypePlugins: [].concat(_toConsumableArray(rehypePluginsCache), _toConsumableArray(rehypePlugins)),
|
|
116
|
+
remarkPlugins: [].concat(_toConsumableArray(remarkPluginsCache), _toConsumableArray(remarkPlugins))
|
|
110
117
|
}, rest), {}, {
|
|
111
118
|
children: escapedContent
|
|
112
119
|
}))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/ui",
|
|
3
|
-
"version": "1.149.
|
|
3
|
+
"version": "1.149.2",
|
|
4
4
|
"description": "Lobe UI is an open-source UI component library for building AIGC web apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lobehub",
|
|
@@ -166,7 +166,8 @@
|
|
|
166
166
|
"antd-style": ">=3",
|
|
167
167
|
"lucide-react": ">=0.396.0",
|
|
168
168
|
"react": ">=18",
|
|
169
|
-
"react-dom": ">=18"
|
|
169
|
+
"react-dom": ">=18",
|
|
170
|
+
"unified": ">=10.0.0"
|
|
170
171
|
},
|
|
171
172
|
"publishConfig": {
|
|
172
173
|
"access": "public",
|