@lobehub/ui 1.147.0 → 1.147.1

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
- var _excluded = ["avatarAddon", "onAvatarClick", "avatarProps", "actions", "className", "primary", "loading", "message", "placement", "type", "avatar", "error", "showTitle", "time", "editing", "onChange", "onEditingChange", "messageExtra", "renderMessage", "text", "errorMessage", "onDoubleClick", "fontSize"];
5
+ var _excluded = ["avatarAddon", "onAvatarClick", "avatarProps", "actions", "className", "primary", "loading", "message", "placement", "type", "avatar", "error", "showTitle", "time", "editing", "onChange", "onEditingChange", "messageExtra", "renderMessage", "text", "errorMessage", "onDoubleClick", "fontSize", "aboveMessage", "belowMessage"];
6
6
  import { useResponsive } from 'antd-style';
7
7
  import { memo } from 'react';
8
8
  import { Flexbox } from 'react-layout-kit';
@@ -42,6 +42,8 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
42
42
  errorMessage = _ref.errorMessage,
43
43
  onDoubleClick = _ref.onDoubleClick,
44
44
  fontSize = _ref.fontSize,
45
+ aboveMessage = _ref.aboveMessage,
46
+ belowMessage = _ref.belowMessage,
45
47
  rest = _objectWithoutProperties(_ref, _excluded);
46
48
  var _useResponsive = useResponsive(),
47
49
  mobile = _useResponsive.mobile;
@@ -76,7 +78,7 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
76
78
  placement: placement,
77
79
  showTitle: showTitle,
78
80
  time: time
79
- }), /*#__PURE__*/_jsxs(Flexbox, {
81
+ }), aboveMessage, /*#__PURE__*/_jsxs(Flexbox, {
80
82
  align: placement === 'left' ? 'flex-start' : 'flex-end',
81
83
  className: styles.messageContent,
82
84
  direction: type === 'block' ? placement === 'left' ? 'horizontal' : 'horizontal-reverse' : 'vertical',
@@ -104,7 +106,7 @@ var ChatItem = /*#__PURE__*/memo(function (_ref) {
104
106
  placement: placement,
105
107
  type: type
106
108
  })]
107
- })]
109
+ }), belowMessage]
108
110
  }), mobile && type === 'block' && /*#__PURE__*/_jsx(BorderSpacing, {
109
111
  borderSpacing: MOBILE_AVATAR_SIZE
110
112
  })]
@@ -1,9 +1,11 @@
1
1
  import { ReactNode } from 'react';
2
+ import { FlexboxProps } from 'react-layout-kit';
2
3
  import { AlertProps } from "../Alert";
3
4
  import { AvatarProps } from "../Avatar";
4
5
  import { EditableMessageProps } from "../EditableMessage";
5
6
  import { DivProps, MetaData } from "../types";
6
- export interface ChatItemProps {
7
+ export interface ChatItemProps extends Omit<FlexboxProps, 'children' | 'onChange'> {
8
+ aboveMessage?: ReactNode;
7
9
  /**
8
10
  * @description Actions to be displayed in the chat item
9
11
  */
@@ -14,10 +16,7 @@ export interface ChatItemProps {
14
16
  avatar: MetaData;
15
17
  avatarAddon?: ReactNode;
16
18
  avatarProps?: AvatarProps;
17
- /**
18
- * @description Custom CSS class name for the chat item
19
- */
20
- className?: string;
19
+ belowMessage?: ReactNode;
21
20
  /**
22
21
  * @description Whether the chat item is in editing mode
23
22
  */
@@ -17,7 +17,7 @@ import Video from "../mdx/Video";
17
17
  import { CodeFullFeatured, CodeLite } from "./CodeBlock";
18
18
  import { useStyles as useMarkdownStyles } from "./markdown.style";
19
19
  import { useStyles } from "./style";
20
- import { escapeBrackets, escapeMhchem } from "./utils";
20
+ import { escapeBrackets, escapeMhchem, fixMarkdownBold } from "./utils";
21
21
  import { jsx as _jsx } from "react/jsx-runtime";
22
22
  var Markdown = /*#__PURE__*/memo(function (_ref) {
23
23
  var children = _ref.children,
@@ -54,8 +54,8 @@ var Markdown = /*#__PURE__*/memo(function (_ref) {
54
54
  mdStyles = _useMarkdownStyles.styles;
55
55
  var isChatMode = variant === 'chat';
56
56
  var escapedContent = useMemo(function () {
57
- if (!enableLatex) return children;
58
- return escapeMhchem(escapeBrackets(children));
57
+ if (!enableLatex) return fixMarkdownBold(children);
58
+ return fixMarkdownBold(escapeMhchem(escapeBrackets(children)));
59
59
  }, [children, enableLatex]);
60
60
  var components = useMemo(function () {
61
61
  return {
@@ -1,2 +1,3 @@
1
1
  export declare function escapeBrackets(text: string): string;
2
2
  export declare function escapeMhchem(text: string): string;
3
+ export declare function fixMarkdownBold(text: string): string;
@@ -13,4 +13,33 @@ export function escapeBrackets(text) {
13
13
  }
14
14
  export function escapeMhchem(text) {
15
15
  return text.replaceAll('$\\ce{', '$\\\\ce{').replaceAll('$\\pu{', '$\\\\pu{');
16
+ }
17
+ export function fixMarkdownBold(text) {
18
+ var count = 0;
19
+ var count2 = 0;
20
+ var result = '';
21
+ for (var i = 0; i < text.length; i++) {
22
+ var char = text[i];
23
+ if (char === '*') {
24
+ count++;
25
+ if (count === 2) {
26
+ count2++;
27
+ }
28
+ if (count > 2) {
29
+ result += char;
30
+ continue;
31
+ }
32
+ if (count === 2 && count2 % 2 === 0) {
33
+ var prevChar = i > 0 ? text[i - 2] : '';
34
+ var isPrevCharAlphanumeric = /[\dA-Za-z]/.test(prevChar);
35
+ result += i + 1 < text.length && text[i + 1] !== ' ' && !isPrevCharAlphanumeric ? '* ' : '*';
36
+ } else {
37
+ result += '*';
38
+ }
39
+ } else {
40
+ result += char;
41
+ count = 0;
42
+ }
43
+ }
44
+ return result;
16
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.147.0",
3
+ "version": "1.147.1",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",