@lobehub/ui 1.150.1 → 1.150.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.
@@ -1,5 +1,5 @@
1
1
  import type { AnchorProps } from 'antd';
2
- import { CSSProperties } from 'react';
2
+ import { CSSProperties, ReactNode } from 'react';
3
3
  import type { Components } from 'react-markdown/lib/ast-to-react';
4
4
  import type { Pluggable } from 'unified';
5
5
  import { type HighlighterProps } from "../Highlighter";
@@ -22,6 +22,9 @@ export interface MarkdownProps extends TypographyProps {
22
22
  video?: Partial<VideoProps>;
23
23
  };
24
24
  components?: Components;
25
+ customRender?: (dom: ReactNode, context: {
26
+ text: string;
27
+ }) => ReactNode;
25
28
  enableImageGallery?: boolean;
26
29
  enableLatex?: boolean;
27
30
  enableMermaid?: boolean;
@@ -3,7 +3,7 @@
3
3
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
4
4
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
5
5
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
6
- var _excluded = ["children", "className", "style", "fullFeaturedCodeBlock", "onDoubleClick", "enableLatex", "enableMermaid", "enableImageGallery", "componentProps", "allowHtml", "fontSize", "headerMultiple", "marginMultiple", "variant", "lineHeight", "rehypePlugins", "remarkPlugins", "components"];
6
+ var _excluded = ["children", "className", "style", "fullFeaturedCodeBlock", "onDoubleClick", "enableLatex", "enableMermaid", "enableImageGallery", "componentProps", "allowHtml", "fontSize", "headerMultiple", "marginMultiple", "variant", "lineHeight", "rehypePlugins", "remarkPlugins", "components", "customRender"];
7
7
  import { memo, useMemo } from 'react';
8
8
  import ReactMarkdown from 'react-markdown';
9
9
  import rehypeKatex from 'rehype-katex';
@@ -46,6 +46,7 @@ var Markdown = /*#__PURE__*/memo(function (_ref) {
46
46
  remarkPlugins = _ref$remarkPlugins === void 0 ? [] : _ref$remarkPlugins,
47
47
  _ref$components = _ref.components,
48
48
  components = _ref$components === void 0 ? {} : _ref$components,
49
+ customRender = _ref.customRender,
49
50
  rest = _objectWithoutProperties(_ref, _excluded);
50
51
  var _useStyles = useStyles({
51
52
  fontSize: fontSize,
@@ -102,22 +103,26 @@ var Markdown = /*#__PURE__*/memo(function (_ref) {
102
103
  var memoRemarkPlugins = useMemo(function () {
103
104
  return [remarkGfm, enableLatex && remarkMath, isChatMode && remarkBreaks].concat(_toConsumableArray(remarkPlugins)).filter(Boolean);
104
105
  }, [isChatMode, enableLatex].concat(_toConsumableArray(remarkPlugins)));
106
+ var defaultDOM = /*#__PURE__*/_jsx(ImageGallery, {
107
+ enable: enableImageGallery,
108
+ children: /*#__PURE__*/_jsx(ReactMarkdown, _objectSpread(_objectSpread({
109
+ 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),
110
+ components: memoComponents,
111
+ rehypePlugins: memoRehypePlugins,
112
+ remarkPlugins: memoRemarkPlugins
113
+ }, rest), {}, {
114
+ children: escapedContent
115
+ }))
116
+ });
117
+ var markdownContent = customRender ? customRender(defaultDOM, {
118
+ text: escapedContent
119
+ }) : defaultDOM;
105
120
  return /*#__PURE__*/_jsx("article", {
106
121
  className: cx(styles.root, className),
107
122
  "data-code-type": "markdown",
108
123
  onDoubleClick: onDoubleClick,
109
124
  style: style,
110
- children: /*#__PURE__*/_jsx(ImageGallery, {
111
- enable: enableImageGallery,
112
- children: /*#__PURE__*/_jsx(ReactMarkdown, _objectSpread(_objectSpread({
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),
114
- components: memoComponents,
115
- rehypePlugins: memoRehypePlugins,
116
- remarkPlugins: memoRemarkPlugins
117
- }, rest), {}, {
118
- children: escapedContent
119
- }))
120
- })
125
+ children: markdownContent
121
126
  });
122
127
  });
123
128
  export default Markdown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.150.1",
3
+ "version": "1.150.2",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",