@yuntijs/ui 1.0.0-beta.11 → 1.0.0-beta.110
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/App/index.d.ts +7 -0
- package/es/App/index.js +19 -0
- package/es/ButtonGroup/index.d.ts +24 -0
- package/es/ButtonGroup/index.js +66 -0
- package/es/CardList/Item/index.d.ts +4 -0
- package/es/CardList/Item/index.js +43 -0
- package/es/CardList/Item/style.d.ts +0 -0
- package/es/CardList/Item/style.js +0 -0
- package/es/CardList/index.d.ts +2 -0
- package/es/CardList/index.js +39 -0
- package/es/ChatInputArea/desktop/ChatInputArea.d.ts +19 -0
- package/es/ChatInputArea/desktop/ChatInputArea.js +72 -0
- package/es/ChatInputArea/index.d.ts +6 -0
- package/es/ChatInputArea/index.js +6 -0
- package/es/ChatItem/components/Actions.d.ts +10 -0
- package/es/ChatItem/components/Actions.js +23 -0
- package/es/ChatItem/components/MessageContent.d.ts +21 -0
- package/es/ChatItem/components/MessageContent.js +59 -0
- package/es/ChatItem/index.d.ts +4 -0
- package/es/ChatItem/index.js +124 -0
- package/es/ChatItem/style.d.ts +25 -0
- package/es/ChatItem/style.js +39 -0
- package/es/ChatItem/type.d.ts +87 -0
- package/es/ChatItem/type.js +1 -0
- package/es/ChatMarkdown/MarkdownElements/AntThinking/Component.d.ts +7 -0
- package/es/ChatMarkdown/MarkdownElements/AntThinking/Component.js +65 -0
- package/es/ChatMarkdown/MarkdownElements/AntThinking/index.d.ts +8 -0
- package/es/ChatMarkdown/MarkdownElements/AntThinking/index.js +10 -0
- package/es/ChatMarkdown/MarkdownElements/AntThinking/rehypePlugin.d.ts +3 -0
- package/es/ChatMarkdown/MarkdownElements/AntThinking/rehypePlugin.js +32 -0
- package/es/ChatMarkdown/MarkdownElements/AntThinking/remarkPlugin.d.ts +1 -0
- package/es/ChatMarkdown/MarkdownElements/AntThinking/remarkPlugin.js +59 -0
- package/es/ChatMarkdown/MarkdownElements/index.d.ts +7 -0
- package/es/ChatMarkdown/MarkdownElements/index.js +2 -0
- package/es/ChatMarkdown/index.d.ts +10 -0
- package/es/ChatMarkdown/index.js +40 -0
- package/es/ChatMarkdown/utils.d.ts +1 -0
- package/es/ChatMarkdown/utils.js +15 -0
- package/es/CodeEditor/index.d.ts +52 -0
- package/es/CodeEditor/index.js +418 -0
- package/es/CodeEditor/style.d.ts +9 -0
- package/es/CodeEditor/style.js +19 -0
- package/es/CollapseGroup/index.d.ts +4 -0
- package/es/CollapseGroup/index.js +39 -0
- package/es/CollapseGroup/style.d.ts +5 -0
- package/es/CollapseGroup/style.js +12 -0
- package/es/ConfigProvider/index.d.ts +3 -0
- package/es/ConfigProvider/index.js +17 -11
- package/es/Descriptions/index.d.ts +0 -1
- package/es/Descriptions/index.js +1 -3
- package/es/Descriptions/style.js +1 -7
- package/es/Divider/index.d.ts +38 -0
- package/es/Divider/index.js +66 -0
- package/es/Divider/style.d.ts +3 -0
- package/es/Divider/style.js +12 -0
- package/es/DragPanel/index.d.ts +10 -0
- package/es/DragPanel/index.js +97 -0
- package/es/DragPanel/style.d.ts +7 -0
- package/es/DragPanel/style.js +15 -0
- package/es/Drawer/index.d.ts +13 -0
- package/es/Drawer/index.js +20 -0
- package/es/Drawer/style.d.ts +4 -0
- package/es/Drawer/style.js +16 -0
- package/es/Dropdown/index.d.ts +14 -0
- package/es/Dropdown/index.js +59 -0
- package/es/Dropdown/style.d.ts +7 -0
- package/es/Dropdown/style.js +13 -0
- package/es/EditableMessage/index.d.ts +76 -0
- package/es/EditableMessage/index.js +100 -0
- package/es/Form/collapse-list/FieldsWatcher.d.ts +7 -0
- package/es/Form/collapse-list/FieldsWatcher.js +19 -0
- package/es/Form/collapse-list/hooks.d.ts +20 -0
- package/es/Form/collapse-list/hooks.js +158 -0
- package/es/Form/collapse-list/index.d.ts +53 -0
- package/es/Form/collapse-list/index.js +313 -0
- package/es/Form/collapse-list/style.d.ts +6 -0
- package/es/Form/collapse-list/style.js +14 -0
- package/es/Form/collapse-list/utils.d.ts +10 -0
- package/es/Form/collapse-list/utils.js +4 -0
- package/es/Form/index.d.ts +8 -0
- package/es/Form/index.js +5 -0
- package/es/FormHelper/autoFocus.d.ts +10 -0
- package/es/FormHelper/autoFocus.js +38 -0
- package/es/FormHelper/index.d.ts +13 -0
- package/es/FormHelper/index.js +41 -0
- package/es/Highlighter/FullFeatured.d.ts +18 -0
- package/es/Highlighter/FullFeatured.js +102 -0
- package/es/Highlighter/SyntaxHighlighter/index.d.ts +7 -0
- package/es/Highlighter/SyntaxHighlighter/index.js +51 -0
- package/es/Highlighter/SyntaxHighlighter/style.d.ts +5 -0
- package/es/Highlighter/SyntaxHighlighter/style.js +16 -0
- package/es/Highlighter/index.d.ts +50 -0
- package/es/Highlighter/index.js +77 -0
- package/es/Highlighter/style.d.ts +9 -0
- package/es/Highlighter/style.js +23 -0
- package/es/Highlighter/theme.d.ts +1 -0
- package/es/Highlighter/theme.js +1661 -0
- package/es/JsonViewer/index.d.ts +30 -0
- package/es/JsonViewer/index.js +125 -0
- package/es/JsonViewer/style.d.ts +7 -0
- package/es/JsonViewer/style.js +19 -0
- package/es/LogViewer/index.d.ts +10 -0
- package/es/LogViewer/index.js +141 -0
- package/es/LogViewer/style.d.ts +6 -0
- package/es/LogViewer/style.js +16 -0
- package/es/LogViewer/types.d.ts +235 -0
- package/es/LogViewer/types.js +1 -0
- package/es/Mentions/constants.d.ts +6 -0
- package/es/Mentions/constants.js +28 -0
- package/es/Mentions/hooks.d.ts +20 -0
- package/es/Mentions/hooks.js +133 -0
- package/es/Mentions/index.d.ts +23 -0
- package/es/Mentions/index.js +157 -0
- package/es/Mentions/plugins/OnBlurBlockPlugin.d.ts +7 -0
- package/es/Mentions/plugins/OnBlurBlockPlugin.js +35 -0
- package/es/Mentions/plugins/custom-text/node.d.ts +11 -0
- package/es/Mentions/plugins/custom-text/node.js +72 -0
- package/es/Mentions/plugins/editable.d.ts +4 -0
- package/es/Mentions/plugins/editable.js +13 -0
- package/es/Mentions/plugins/mention-node/component.d.ts +6 -0
- package/es/Mentions/plugins/mention-node/component.js +64 -0
- package/es/Mentions/plugins/mention-node/index.d.ts +9 -0
- package/es/Mentions/plugins/mention-node/index.js +32 -0
- package/es/Mentions/plugins/mention-node/node.d.ts +22 -0
- package/es/Mentions/plugins/mention-node/node.js +100 -0
- package/es/Mentions/plugins/mention-node/replacement.d.ts +5 -0
- package/es/Mentions/plugins/mention-node/replacement.js +43 -0
- package/es/Mentions/plugins/mention-node/style.d.ts +8 -0
- package/es/Mentions/plugins/mention-node/style.js +47 -0
- package/es/Mentions/plugins/mention-node/utils.d.ts +4 -0
- package/es/Mentions/plugins/mention-node/utils.js +10 -0
- package/es/Mentions/plugins/mention-picker/hooks.d.ts +5 -0
- package/es/Mentions/plugins/mention-picker/hooks.js +65 -0
- package/es/Mentions/plugins/mention-picker/index.d.ts +39 -0
- package/es/Mentions/plugins/mention-picker/index.js +137 -0
- package/es/Mentions/plugins/mention-picker/menu-item.d.ts +12 -0
- package/es/Mentions/plugins/mention-picker/menu-item.js +73 -0
- package/es/Mentions/plugins/mention-picker/menu.d.ts +10 -0
- package/es/Mentions/plugins/mention-picker/menu.js +31 -0
- package/es/Mentions/plugins/mention-picker/style.d.ts +11 -0
- package/es/Mentions/plugins/mention-picker/style.js +19 -0
- package/es/Mentions/plugins/mention-picker/utils.d.ts +31 -0
- package/es/Mentions/plugins/mention-picker/utils.js +66 -0
- package/es/Mentions/provider.d.ts +12 -0
- package/es/Mentions/provider.js +15 -0
- package/es/Mentions/style.d.ts +11 -0
- package/es/Mentions/style.js +22 -0
- package/es/Mentions/types.d.ts +12 -0
- package/es/Mentions/types.js +1 -0
- package/es/Mentions/utils.d.ts +9 -0
- package/es/Mentions/utils.js +95 -0
- package/es/Modal/index.d.ts +19 -0
- package/es/Modal/index.js +36 -0
- package/es/Modal/style.d.ts +4 -0
- package/es/Modal/style.js +17 -0
- package/es/MonacoEditor/base/controller.d.ts +17 -0
- package/es/MonacoEditor/base/controller.js +49 -0
- package/es/MonacoEditor/base/helper.d.ts +65 -0
- package/es/MonacoEditor/base/helper.js +324 -0
- package/es/MonacoEditor/base/index.d.ts +39 -0
- package/es/MonacoEditor/base/index.js +238 -0
- package/es/MonacoEditor/base/monaco.d.ts +6 -0
- package/es/MonacoEditor/base/monaco.js +64 -0
- package/es/MonacoEditor/{style.d.ts → base/style.d.ts} +4 -1
- package/es/MonacoEditor/base/style.js +43 -0
- package/es/MonacoEditor/index.d.ts +5 -4
- package/es/MonacoEditor/index.js +26 -62
- package/es/Page/Breadcrumb/index.d.ts +9 -0
- package/es/Page/Breadcrumb/index.js +56 -0
- package/es/Page/Content/index.d.ts +4 -0
- package/es/Page/Content/index.js +59 -0
- package/es/Page/Content/style.d.ts +3 -0
- package/es/Page/Content/style.js +12 -0
- package/es/Page/Footer/index.d.ts +2 -0
- package/es/Page/Footer/index.js +6 -0
- package/es/Page/Header/Icon.d.ts +17 -0
- package/es/Page/Header/Icon.js +42 -0
- package/es/Page/Header/index.d.ts +43 -0
- package/es/Page/Header/index.js +202 -0
- package/es/Page/Header/style.d.ts +12 -0
- package/es/Page/Header/style.js +21 -0
- package/es/Page/Page.d.ts +9 -0
- package/es/Page/Page.js +49 -0
- package/es/Page/PageContext.d.ts +15 -0
- package/es/Page/PageContext.js +21 -0
- package/es/Page/Title/index.d.ts +5 -0
- package/es/Page/Title/index.js +18 -0
- package/es/Page/Title/style.d.ts +3 -0
- package/es/Page/Title/style.js +10 -0
- package/es/Page/index.d.ts +18 -0
- package/es/Page/index.js +15 -0
- package/es/Page/style.d.ts +3 -0
- package/es/Page/style.js +10 -0
- package/es/ProCard/Card/index.d.ts +6 -0
- package/es/ProCard/Card/index.js +25 -0
- package/es/ProCard/Card/style.d.ts +7 -0
- package/es/ProCard/Card/style.js +15 -0
- package/es/ProCard/Content/index.d.ts +4 -0
- package/es/ProCard/Content/index.js +24 -0
- package/es/ProCard/Content/style.d.ts +3 -0
- package/es/ProCard/Content/style.js +10 -0
- package/es/ProCard/Descriptions/index.d.ts +4 -0
- package/es/ProCard/Descriptions/index.js +28 -0
- package/es/ProCard/Descriptions/style.d.ts +3 -0
- package/es/ProCard/Descriptions/style.js +12 -0
- package/es/ProCard/Header/index.d.ts +15 -0
- package/es/ProCard/Header/index.js +86 -0
- package/es/ProCard/Header/style.d.ts +12 -0
- package/es/ProCard/Header/style.js +21 -0
- package/es/ProCard/index.d.ts +13 -0
- package/es/ProCard/index.js +8 -0
- package/es/SelectCard/index.d.ts +33 -0
- package/es/SelectCard/index.js +132 -0
- package/es/SelectCard/style.d.ts +10 -0
- package/es/SelectCard/style.js +42 -0
- package/es/SliderInput/index.js +2 -2
- package/es/Status/index.d.ts +7 -0
- package/es/Status/index.js +39 -0
- package/es/Status/style.d.ts +4 -0
- package/es/Status/style.js +14 -0
- package/es/Table/collapse/index.d.ts +9 -0
- package/es/Table/collapse/index.js +39 -0
- package/es/Table/collapse/style.d.ts +3 -0
- package/es/Table/collapse/style.js +11 -0
- package/es/Table/index.d.ts +20 -0
- package/es/Table/index.js +56 -0
- package/es/Typography/index.d.ts +32 -0
- package/es/Typography/index.js +77 -0
- package/es/WaveformIcon/index.d.ts +9 -0
- package/es/WaveformIcon/index.js +51 -0
- package/es/hooks/languageMap.d.ts +1 -0
- package/es/hooks/languageMap.js +1 -0
- package/es/hooks/useHighlight.d.ts +5 -0
- package/es/hooks/useHighlight.js +82 -0
- package/es/index.d.ts +36 -5
- package/es/index.js +44 -6
- package/es/notification/index.d.ts +24 -0
- package/es/notification/index.js +237 -0
- package/es/notification/style.d.ts +2 -0
- package/es/notification/style.js +28 -0
- package/es/styles/colors/colors.d.ts +39 -0
- package/es/styles/colors/colors.js +86 -0
- package/es/styles/colors/generateColorPalette.d.ts +11 -0
- package/es/styles/colors/generateColorPalette.js +31 -0
- package/es/styles/colors/neutralColors.d.ts +9 -0
- package/es/styles/colors/neutralColors.js +32 -0
- package/es/styles/index.d.ts +4 -0
- package/es/styles/index.js +4 -0
- package/es/useSpeechSynthes/const/polyfill.d.ts +3 -0
- package/es/useSpeechSynthes/const/polyfill.js +21 -0
- package/es/useSpeechSynthes/index.d.ts +13 -0
- package/es/useSpeechSynthes/index.js +69 -0
- package/es/utils/constants.d.ts +1 -0
- package/es/utils/constants.js +1 -0
- package/es/utils/platform.d.ts +1 -0
- package/es/utils/platform.js +1 -0
- package/es/utils/tools.d.ts +1 -0
- package/es/utils/tools.js +1 -0
- package/package.json +34 -9
- package/umd/index.min.css +2 -0
- package/umd/index.min.css.map +1 -0
- package/umd/index.min.js +1 -1
- package/umd/index.min.js.map +1 -1
- package/es/MonacoEditor/style.js +0 -24
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { AlertProps, AvatarProps, DivProps, MetaData } from '@lobehub/ui';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import type { EditableMessageProps } from "../EditableMessage";
|
|
4
|
+
export interface ChatItemProps {
|
|
5
|
+
/**
|
|
6
|
+
* @description Actions to be displayed in the chat item
|
|
7
|
+
*/
|
|
8
|
+
actions?: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* @description Metadata for the avatar
|
|
11
|
+
*/
|
|
12
|
+
avatar: MetaData;
|
|
13
|
+
avatarAddon?: ReactNode;
|
|
14
|
+
avatarProps?: AvatarProps;
|
|
15
|
+
/**
|
|
16
|
+
* @description Custom CSS class name for the chat item
|
|
17
|
+
*/
|
|
18
|
+
className?: string;
|
|
19
|
+
/**
|
|
20
|
+
* @description Whether the chat item is in editing mode
|
|
21
|
+
*/
|
|
22
|
+
editing?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* @description Props for Error render
|
|
25
|
+
*/
|
|
26
|
+
error?: AlertProps;
|
|
27
|
+
errorMessage?: ReactNode;
|
|
28
|
+
fontSize?: number;
|
|
29
|
+
/**
|
|
30
|
+
* @description Whether the chat item is in loading state
|
|
31
|
+
*/
|
|
32
|
+
loading?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* @description The message content of the chat item
|
|
35
|
+
*/
|
|
36
|
+
message?: ReactNode;
|
|
37
|
+
messageExtra?: ReactNode;
|
|
38
|
+
affixation?: ReactNode;
|
|
39
|
+
onAvatarClick?: () => void;
|
|
40
|
+
/**
|
|
41
|
+
* @description Callback when the message content changes
|
|
42
|
+
* @param value - The new message content
|
|
43
|
+
*/
|
|
44
|
+
onChange?: (value: string) => void;
|
|
45
|
+
onDoubleClick?: DivProps['onDoubleClick'];
|
|
46
|
+
/**
|
|
47
|
+
* @description Callback when the editing mode changes
|
|
48
|
+
* @param editing - The new editing mode
|
|
49
|
+
*/
|
|
50
|
+
onEditingChange?: (editing: boolean) => void;
|
|
51
|
+
/**
|
|
52
|
+
* @description The placement of the chat item
|
|
53
|
+
* @default 'left'
|
|
54
|
+
*/
|
|
55
|
+
placement?: 'left' | 'right';
|
|
56
|
+
/**
|
|
57
|
+
* @description Whether the chat item is primary
|
|
58
|
+
*/
|
|
59
|
+
primary?: boolean;
|
|
60
|
+
renderMessage?: (content: ReactNode) => ReactNode;
|
|
61
|
+
/**
|
|
62
|
+
* @description Whether to show the title of the chat item
|
|
63
|
+
*/
|
|
64
|
+
showTitle?: boolean;
|
|
65
|
+
text?: EditableMessageProps['text'];
|
|
66
|
+
/**
|
|
67
|
+
* @description The timestamp of the chat item
|
|
68
|
+
*/
|
|
69
|
+
time?: number;
|
|
70
|
+
/**
|
|
71
|
+
* @description The type of the chat item
|
|
72
|
+
* @default 'block'
|
|
73
|
+
*/
|
|
74
|
+
type?: 'block' | 'pure';
|
|
75
|
+
/**
|
|
76
|
+
* @description The markdownProps of the chat item
|
|
77
|
+
*/
|
|
78
|
+
markdownProps?: EditableMessageProps['markdownProps'];
|
|
79
|
+
/**
|
|
80
|
+
* @description The markdownClassname of the chat item
|
|
81
|
+
*/
|
|
82
|
+
markdownClassname?: string;
|
|
83
|
+
/**
|
|
84
|
+
* @description Whether this message is latest
|
|
85
|
+
*/
|
|
86
|
+
isLatest?: boolean;
|
|
87
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
4
|
+
var _templateObject, _templateObject2;
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
+
import { Icon, Markdown } from '@lobehub/ui';
|
|
8
|
+
import { createStyles } from 'antd-style';
|
|
9
|
+
import { ChevronDown, ChevronRight, Sparkles } from 'lucide-react';
|
|
10
|
+
import { memo, useState } from 'react';
|
|
11
|
+
import { Flexbox } from 'react-layout-kit';
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
var useStyles = createStyles(function (_ref) {
|
|
15
|
+
var css = _ref.css,
|
|
16
|
+
token = _ref.token,
|
|
17
|
+
isDarkMode = _ref.isDarkMode;
|
|
18
|
+
return {
|
|
19
|
+
container: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding-block: 12px;\n color: ", ";\n "])), token.colorTextSecondary),
|
|
20
|
+
titlebox: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n cursor: pointer;\n\n min-width: 140px;\n max-width: 230px;\n padding: 8px 12px;\n\n font-size: 12px;\n color: ", ";\n\n background: ", ";\n border-radius: 8px;\n "])), token.colorText, isDarkMode ? token.colorFillTertiary : '#f3f5fc')
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
var mProps = {
|
|
24
|
+
fontSize: 13,
|
|
25
|
+
lineHeight: 1.625,
|
|
26
|
+
headerMultiple: 0.2,
|
|
27
|
+
marginMultiple: 0.6
|
|
28
|
+
};
|
|
29
|
+
var Render = /*#__PURE__*/memo(function (_ref2) {
|
|
30
|
+
var children = _ref2.children,
|
|
31
|
+
second = _ref2.second,
|
|
32
|
+
done = _ref2.done;
|
|
33
|
+
var _useStyles = useStyles(),
|
|
34
|
+
styles = _useStyles.styles,
|
|
35
|
+
theme = _useStyles.theme;
|
|
36
|
+
var _useState = useState(true),
|
|
37
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
38
|
+
showDetail = _useState2[0],
|
|
39
|
+
setShowDetail = _useState2[1];
|
|
40
|
+
return /*#__PURE__*/_jsxs(Flexbox, {
|
|
41
|
+
className: styles.container,
|
|
42
|
+
children: [/*#__PURE__*/_jsxs(Flexbox, {
|
|
43
|
+
className: styles.titlebox,
|
|
44
|
+
distribution: 'space-between',
|
|
45
|
+
flex: 1,
|
|
46
|
+
horizontal: true,
|
|
47
|
+
onClick: function onClick() {
|
|
48
|
+
setShowDetail(!showDetail);
|
|
49
|
+
},
|
|
50
|
+
children: [/*#__PURE__*/_jsxs(Flexbox, {
|
|
51
|
+
gap: 8,
|
|
52
|
+
horizontal: true,
|
|
53
|
+
children: [/*#__PURE__*/_jsx(Icon, {
|
|
54
|
+
color: theme.purple,
|
|
55
|
+
icon: Sparkles
|
|
56
|
+
}), done ? "\u5DF2\u6DF1\u5EA6\u601D\u8003".concat(second ? '(用时 ' + second + ' s)' : '', " ") : '思考中...']
|
|
57
|
+
}), /*#__PURE__*/_jsx(Icon, {
|
|
58
|
+
icon: showDetail ? ChevronDown : ChevronRight
|
|
59
|
+
})]
|
|
60
|
+
}), showDetail && /*#__PURE__*/_jsx(Markdown, _objectSpread(_objectSpread({}, mProps), {}, {
|
|
61
|
+
children: children
|
|
62
|
+
}))]
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
export default Render;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const AntThinkingElement: {
|
|
3
|
+
Component: import("react").NamedExoticComponent<import("react").PropsWithChildren<import("./Component").ThinkProps>>;
|
|
4
|
+
rehypePlugin: () => (tree: import("unist").Node) => void;
|
|
5
|
+
remarkPlugins: () => (tree: any) => void;
|
|
6
|
+
tag: string;
|
|
7
|
+
};
|
|
8
|
+
export default AntThinkingElement;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import Component from "./Component";
|
|
2
|
+
import rehypePlugin from "./rehypePlugin";
|
|
3
|
+
import { remarkCaptureThink } from "./remarkPlugin";
|
|
4
|
+
var AntThinkingElement = {
|
|
5
|
+
Component: Component,
|
|
6
|
+
rehypePlugin: rehypePlugin,
|
|
7
|
+
remarkPlugins: remarkCaptureThink,
|
|
8
|
+
tag: 'think'
|
|
9
|
+
};
|
|
10
|
+
export default AntThinkingElement;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { visit } from 'unist-util-visit';
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line unicorn/consistent-function-scoping
|
|
4
|
+
var rehypePlugin = function rehypePlugin() {
|
|
5
|
+
return function (tree) {
|
|
6
|
+
visit(tree, 'element', function (node, index, parent) {
|
|
7
|
+
if (node.type === 'element' && node.tagName === 'p') {
|
|
8
|
+
var children = node.children || [];
|
|
9
|
+
var openTagIndex = children.findIndex(function (child) {
|
|
10
|
+
return child.type === 'raw' && child.value === '<think>';
|
|
11
|
+
});
|
|
12
|
+
var closeTagIndex = children.findIndex(function (child) {
|
|
13
|
+
return child.type === 'raw' && child.value === '</think>';
|
|
14
|
+
});
|
|
15
|
+
if (openTagIndex !== -1 && closeTagIndex !== -1 && closeTagIndex > openTagIndex) {
|
|
16
|
+
var content = children.slice(openTagIndex + 1, closeTagIndex);
|
|
17
|
+
var thinkNode = {
|
|
18
|
+
children: content,
|
|
19
|
+
properties: {},
|
|
20
|
+
tagName: 'think',
|
|
21
|
+
type: 'element'
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// Replace the entire paragraph with our new thinkNode node
|
|
25
|
+
parent.children.splice(index, 1, thinkNode);
|
|
26
|
+
return index; // Skip processing the newly inserted node
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export default rehypePlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const remarkCaptureThink: () => (tree: any) => void;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { toMarkdown } from 'mdast-util-to-markdown';
|
|
2
|
+
import { SKIP, visit } from 'unist-util-visit';
|
|
3
|
+
export var remarkCaptureThink = function remarkCaptureThink() {
|
|
4
|
+
return function (tree) {
|
|
5
|
+
visit(tree, 'html', function (node, index, parent) {
|
|
6
|
+
if (node.value === '<think>') {
|
|
7
|
+
var startIndex = index;
|
|
8
|
+
var endIndex = startIndex + 1;
|
|
9
|
+
var hasCloseTag = false;
|
|
10
|
+
|
|
11
|
+
// 查找闭合标签
|
|
12
|
+
while (endIndex < parent.children.length) {
|
|
13
|
+
var sibling = parent.children[endIndex];
|
|
14
|
+
if (sibling.type === 'html' && sibling.value === '</think>') {
|
|
15
|
+
hasCloseTag = true;
|
|
16
|
+
break;
|
|
17
|
+
}
|
|
18
|
+
endIndex++;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// 计算需要删除的节点范围
|
|
22
|
+
var deleteCount = hasCloseTag ? endIndex - startIndex + 1 : parent.children.length - startIndex;
|
|
23
|
+
|
|
24
|
+
// 提取内容节点
|
|
25
|
+
var contentNodes = parent.children.slice(startIndex + 1, hasCloseTag ? endIndex : undefined);
|
|
26
|
+
|
|
27
|
+
// 转换为 Markdown 字符串
|
|
28
|
+
var content = contentNodes.map(function (n) {
|
|
29
|
+
// fix https://github.com/lobehub/lobe-chat/issues/5668
|
|
30
|
+
if (n.type === 'paragraph') {
|
|
31
|
+
return n.children.map(function (child) {
|
|
32
|
+
return child.value;
|
|
33
|
+
}).join('');
|
|
34
|
+
}
|
|
35
|
+
return toMarkdown(n);
|
|
36
|
+
}).join('\n\n').trim();
|
|
37
|
+
|
|
38
|
+
// 创建自定义节点
|
|
39
|
+
var thinkNode = {
|
|
40
|
+
data: {
|
|
41
|
+
hChildren: [{
|
|
42
|
+
type: 'text',
|
|
43
|
+
value: content || ' '
|
|
44
|
+
}],
|
|
45
|
+
hName: 'think'
|
|
46
|
+
},
|
|
47
|
+
position: node.position,
|
|
48
|
+
type: 'thinkBlock'
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// 替换原始节点
|
|
52
|
+
parent.children.splice(startIndex, deleteCount, thinkNode);
|
|
53
|
+
|
|
54
|
+
// 跳过已处理的节点
|
|
55
|
+
return [SKIP, startIndex + 1];
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const markdownElements: {
|
|
3
|
+
Component: import("react").NamedExoticComponent<import("react").PropsWithChildren<import("./AntThinking/Component").ThinkProps>>;
|
|
4
|
+
rehypePlugin: () => (tree: import("unist").Node) => void;
|
|
5
|
+
remarkPlugins: () => (tree: any) => void;
|
|
6
|
+
tag: string;
|
|
7
|
+
}[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type MarkdownProps } from '@lobehub/ui';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ThinkProps } from './MarkdownElements/AntThinking/Component';
|
|
4
|
+
export interface ChatMarkdownProps extends MarkdownProps {
|
|
5
|
+
customComponentProps?: {
|
|
6
|
+
think?: Partial<ThinkProps>;
|
|
7
|
+
[k: string]: any;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare const ChatMarkdown: React.FC<ChatMarkdownProps>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["components", "remarkPlugins", "customComponentProps", "children"];
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
+
import { Markdown } from '@lobehub/ui';
|
|
8
|
+
import React, { useMemo } from 'react';
|
|
9
|
+
import { markdownElements } from "./MarkdownElements";
|
|
10
|
+
import { normalizeThinkTags } from "./utils";
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
var defaultRemarkPlugins = markdownElements.map(function (element) {
|
|
13
|
+
return element.remarkPlugins;
|
|
14
|
+
});
|
|
15
|
+
export var ChatMarkdown = function ChatMarkdown(_ref) {
|
|
16
|
+
var _ref$components = _ref.components,
|
|
17
|
+
components = _ref$components === void 0 ? {} : _ref$components,
|
|
18
|
+
_ref$remarkPlugins = _ref.remarkPlugins,
|
|
19
|
+
remarkPlugins = _ref$remarkPlugins === void 0 ? [] : _ref$remarkPlugins,
|
|
20
|
+
customComponentProps = _ref.customComponentProps,
|
|
21
|
+
children = _ref.children,
|
|
22
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
23
|
+
var allComponents = useMemo(function () {
|
|
24
|
+
var defaultComponents = Object.fromEntries(markdownElements.map(function (element) {
|
|
25
|
+
return [element.tag, function (aprops) {
|
|
26
|
+
return /*#__PURE__*/_jsx(element.Component, _objectSpread(_objectSpread({}, aprops), customComponentProps === null || customComponentProps === void 0 ? void 0 : customComponentProps[element.tag]));
|
|
27
|
+
}];
|
|
28
|
+
}));
|
|
29
|
+
return _objectSpread(_objectSpread({}, defaultComponents), components);
|
|
30
|
+
}, [components, customComponentProps]);
|
|
31
|
+
var allRemarkPlugins = useMemo(function () {
|
|
32
|
+
return [].concat(_toConsumableArray(defaultRemarkPlugins), _toConsumableArray(remarkPlugins));
|
|
33
|
+
}, [remarkPlugins]);
|
|
34
|
+
return /*#__PURE__*/_jsx(Markdown, _objectSpread(_objectSpread({
|
|
35
|
+
components: allComponents,
|
|
36
|
+
remarkPlugins: allRemarkPlugins
|
|
37
|
+
}, props), {}, {
|
|
38
|
+
children: normalizeThinkTags(children)
|
|
39
|
+
}));
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const normalizeThinkTags: (markdown: string) => string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// 预处理函数:确保 think 标签前后有两个换行符
|
|
2
|
+
export var normalizeThinkTags = function normalizeThinkTags(markdown) {
|
|
3
|
+
var reg1 = new RegExp('([^\\n])\\s*<think>', 'g');
|
|
4
|
+
var reg2 = new RegExp('<think>\\s*([^\\n])', 'g');
|
|
5
|
+
var reg3 = new RegExp('([^\\n])\\s*<\\/think>', 'g');
|
|
6
|
+
var reg4 = new RegExp('<\\/think>\\s*([^\\n])', 'g');
|
|
7
|
+
var reg5 = new RegExp('\\n{3,}', 'g');
|
|
8
|
+
return (markdown || ''
|
|
9
|
+
// 确保 <think> 标签前后有两个换行符
|
|
10
|
+
).replaceAll(reg1, '$1\n\n<think>').replaceAll(reg2, '<think>\n\n$1')
|
|
11
|
+
// 确保 </think> 标签前后有两个换行符
|
|
12
|
+
.replaceAll(reg3, '$1\n\n</think>').replaceAll(reg4, '</think>\n\n$1')
|
|
13
|
+
// 处理可能产生的多余换行符
|
|
14
|
+
.replaceAll(reg5, '\n\n');
|
|
15
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { CSSProperties, FocusEventHandler, KeyboardEventHandler, MouseEventHandler, Ref } from 'react';
|
|
2
|
+
import { FlexboxProps } from 'react-layout-kit';
|
|
3
|
+
export interface CodeEditorProps extends Omit<FlexboxProps, 'onFocus' | 'onBlur' | 'onKeyUp' | 'onKeyDown' | 'onClick'> {
|
|
4
|
+
autoFocus?: boolean;
|
|
5
|
+
classNames?: {
|
|
6
|
+
highlight?: string;
|
|
7
|
+
textarea?: string;
|
|
8
|
+
};
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
fontSize?: number | string;
|
|
11
|
+
form?: string;
|
|
12
|
+
ignoreTabKey?: boolean;
|
|
13
|
+
insertSpaces?: boolean;
|
|
14
|
+
language: string;
|
|
15
|
+
maxLength?: number;
|
|
16
|
+
minLength?: number;
|
|
17
|
+
onBlur?: FocusEventHandler<HTMLTextAreaElement>;
|
|
18
|
+
onClick?: MouseEventHandler<HTMLTextAreaElement>;
|
|
19
|
+
onFocus?: FocusEventHandler<HTMLTextAreaElement>;
|
|
20
|
+
onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;
|
|
21
|
+
onKeyUp?: KeyboardEventHandler<HTMLTextAreaElement>;
|
|
22
|
+
onValueChange: (value: string) => void;
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
readOnly?: boolean;
|
|
25
|
+
required?: boolean;
|
|
26
|
+
style?: CSSProperties;
|
|
27
|
+
styles?: {
|
|
28
|
+
highlight?: CSSProperties;
|
|
29
|
+
textarea?: CSSProperties;
|
|
30
|
+
};
|
|
31
|
+
tabSize?: number;
|
|
32
|
+
textareaId?: string;
|
|
33
|
+
value: string;
|
|
34
|
+
variant?: 'ghost' | 'block' | 'pure';
|
|
35
|
+
}
|
|
36
|
+
type Record = {
|
|
37
|
+
selectionEnd: number;
|
|
38
|
+
selectionStart: number;
|
|
39
|
+
value: string;
|
|
40
|
+
};
|
|
41
|
+
type History = {
|
|
42
|
+
offset: number;
|
|
43
|
+
stack: (Record & {
|
|
44
|
+
timestamp: number;
|
|
45
|
+
})[];
|
|
46
|
+
};
|
|
47
|
+
export declare const CodeEditor: import("react").ForwardRefExoticComponent<CodeEditorProps & import("react").RefAttributes<Ref<{
|
|
48
|
+
session: {
|
|
49
|
+
history: History;
|
|
50
|
+
};
|
|
51
|
+
} | null>>>;
|
|
52
|
+
export {};
|