@antv/dumi-theme-antv 0.8.0-beta.11 → 0.8.0-beta.12
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/dist/components/AI/HomeDialog/RecommendCase/index.module.less +1 -0
- package/dist/pages/AIPlayground/components/ConversationsMenu/index.js +2 -5
- package/dist/pages/AIPlayground/components/MarkdownComponent/MarkdownCodeBlock.js +10 -6
- package/dist/pages/AIPlayground/components/MsgBox/index.js +15 -8
- package/dist/pages/AIPlayground/components/SessionLayout/index.js +48 -13
- package/dist/pages/AIPlayground/components/SessionLayout/index.module.less +1 -1
- package/dist/pages/AIPlayground/components/TaskBox/index.js +1 -0
- package/dist/slots/CodeEditor/index.js +4 -2
- package/dist/slots/CodeRunner/index.js +20 -11
- package/package.json +1 -1
|
@@ -4,13 +4,13 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
4
4
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
5
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
-
import React, {
|
|
7
|
+
import React, { useState } from 'react';
|
|
8
8
|
import { DeleteOutlined, EditOutlined, EllipsisOutlined, HistoryOutlined, MenuFoldOutlined, MenuUnfoldOutlined, PlusSquareOutlined, VerticalAlignTopOutlined } from '@ant-design/icons';
|
|
9
9
|
import { Dropdown, Input, Modal } from 'antd';
|
|
10
10
|
import { Menu } from 'antd';
|
|
11
11
|
import styles from "./index.module.less";
|
|
12
12
|
import { useSnapshot } from 'valtio';
|
|
13
|
-
import { AIChatStore,
|
|
13
|
+
import { AIChatStore, createPureNewSession, handleDeleteSession, handlePinSession, handleRenameSession } from "../../../../model/AIChat";
|
|
14
14
|
import { useSetState } from "ahooks";
|
|
15
15
|
import { useIntl } from 'dumi';
|
|
16
16
|
import { isUUID } from "../../../../utils";
|
|
@@ -28,9 +28,6 @@ export var ConversationsMenu = function ConversationsMenu() {
|
|
|
28
28
|
collapsed = _useState2[0],
|
|
29
29
|
setCollapsed = _useState2[1];
|
|
30
30
|
var snap = useSnapshot(AIChatStore);
|
|
31
|
-
useEffect(function () {
|
|
32
|
-
clearEmptySession();
|
|
33
|
-
}, []);
|
|
34
31
|
var handleSelectSession = function handleSelectSession(sessionId) {
|
|
35
32
|
if (isUUID(sessionId)) {
|
|
36
33
|
AIChatStore.activeSessionId = sessionId;
|
|
@@ -6,13 +6,13 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
7
|
import React from 'react';
|
|
8
8
|
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
|
|
9
|
-
import { a11yLight } from
|
|
9
|
+
import { a11yLight } from 'react-syntax-highlighter/dist/cjs/styles/hljs';
|
|
10
10
|
import { AIChatStore } from "../../../../model/AIChat";
|
|
11
|
-
import { useCopyToClipboard } from
|
|
12
|
-
import { CheckOutlined, CopyOutlined, PlaySquareOutlined } from
|
|
13
|
-
import { Button, Space, Tooltip } from
|
|
11
|
+
import { useCopyToClipboard } from 'react-use';
|
|
12
|
+
import { CheckOutlined, CopyOutlined, PlaySquareOutlined } from '@ant-design/icons';
|
|
13
|
+
import { Button, Space, Tooltip } from 'antd';
|
|
14
14
|
import styles from "./MarkdownCodeBlock.module.less";
|
|
15
|
-
import { useIntl } from 'dumi';
|
|
15
|
+
import { useIntl } from 'dumi'; // 定义 props 类型,它将接收 react-markdown 传递的所有属性
|
|
16
16
|
|
|
17
17
|
// 定义 props 类型,它将接收 react-markdown 传递的所有属性
|
|
18
18
|
|
|
@@ -28,7 +28,7 @@ export var MarkdownCodeBlock = function MarkdownCodeBlock(_ref) {
|
|
|
28
28
|
copyState = _useCopyToClipboard2[0],
|
|
29
29
|
copyToClipboard = _useCopyToClipboard2[1];
|
|
30
30
|
// 1. 处理行内代码:如果是行内代码,不做特殊处理,直接返回一个 <code> 标签
|
|
31
|
-
if (inline || typeof children === 'string' && !children.includes(
|
|
31
|
+
if (inline || typeof children === 'string' && !children.includes('\n')) {
|
|
32
32
|
return /*#__PURE__*/React.createElement("code", {
|
|
33
33
|
className: className
|
|
34
34
|
}, children);
|
|
@@ -88,5 +88,9 @@ export var MarkdownCodeBlock = function MarkdownCodeBlock(_ref) {
|
|
|
88
88
|
PreTag: "div" // 使用 div 作为外层标签,避免 pre 标签的默认样式冲突
|
|
89
89
|
,
|
|
90
90
|
showLineNumbers: false // (可选) 显示行号
|
|
91
|
+
,
|
|
92
|
+
customStyle: {
|
|
93
|
+
paddingTop: '2em'
|
|
94
|
+
}
|
|
91
95
|
}, codeString));
|
|
92
96
|
};
|
|
@@ -15,7 +15,7 @@ import React, { useEffect, useState, useMemo, useRef } from 'react';
|
|
|
15
15
|
import { useCopyToClipboard } from 'react-use';
|
|
16
16
|
import { useSnapshot } from 'valtio';
|
|
17
17
|
import { PromptTextarea } from "../../../../components/AI/HomeDialog/PromptTextarea";
|
|
18
|
-
import { AIChatStore, createPureNewSession, derivedState } from "../../../../model/AIChat";
|
|
18
|
+
import { AIChatStore, clearEmptySession, createPureNewSession, derivedState } from "../../../../model/AIChat";
|
|
19
19
|
import { getCodeFromMarkdown, isPreviewable } from "../../../../utils/code";
|
|
20
20
|
import { MarkdownComponent } from "../MarkdownComponent";
|
|
21
21
|
import styles from "./index.module.less";
|
|
@@ -112,13 +112,15 @@ function MsgBox(props) {
|
|
|
112
112
|
// xxx
|
|
113
113
|
},
|
|
114
114
|
// body 可以是函数,用于获取最新的动态值
|
|
115
|
-
body: {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
115
|
+
body: function body() {
|
|
116
|
+
return {
|
|
117
|
+
gptConversationId: activeSessionIdRef.current,
|
|
118
|
+
anonymousUserId: anonymousUserIdRef.current,
|
|
119
|
+
mountId: 'container',
|
|
120
|
+
antvContext: (latestUserMessage === null || latestUserMessage === void 0 ? void 0 : latestUserMessage.context) || props.context,
|
|
121
|
+
library: AIChatStore.lib,
|
|
122
|
+
mode: latestUserMessage === null || latestUserMessage === void 0 ? void 0 : latestUserMessage.mode
|
|
123
|
+
};
|
|
122
124
|
}
|
|
123
125
|
}),
|
|
124
126
|
messages: convertedInitialMessages,
|
|
@@ -236,6 +238,11 @@ function MsgBox(props) {
|
|
|
236
238
|
if (simple) {
|
|
237
239
|
createPureNewSession(title);
|
|
238
240
|
}
|
|
241
|
+
return function () {
|
|
242
|
+
if (simple) {
|
|
243
|
+
clearEmptySession();
|
|
244
|
+
}
|
|
245
|
+
};
|
|
239
246
|
}, []);
|
|
240
247
|
useEffect(function () {
|
|
241
248
|
chatScrollIntoView();
|
|
@@ -1,25 +1,60 @@
|
|
|
1
|
-
function
|
|
2
|
-
function
|
|
3
|
-
function
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { ConversationsMenu } from "../ConversationsMenu";
|
|
8
|
-
import { AIChatStore } from "../../../../model/AIChat";
|
|
9
|
-
import { useSnapshot } from 'valtio';
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
10
7
|
import classnames from 'classnames';
|
|
8
|
+
import React, { useState } from 'react';
|
|
9
|
+
import SplitPane from 'react-split-pane';
|
|
10
|
+
import { useSnapshot } from 'valtio';
|
|
11
|
+
import { AIChatStore } from "../../../../model/AIChat";
|
|
12
|
+
import { ConversationsMenu } from "../ConversationsMenu";
|
|
13
|
+
import styles from "./index.module.less";
|
|
11
14
|
function SessionLayout(props) {
|
|
12
15
|
var children = props.children;
|
|
13
16
|
var snap = useSnapshot(AIChatStore);
|
|
17
|
+
var _useState = useState(false),
|
|
18
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
19
|
+
isDragging = _useState2[0],
|
|
20
|
+
setIsDragging = _useState2[1];
|
|
14
21
|
if (!Array.isArray(children)) {
|
|
15
22
|
return null;
|
|
16
23
|
}
|
|
17
24
|
return /*#__PURE__*/React.createElement("div", {
|
|
18
25
|
className: styles.container
|
|
19
|
-
}, /*#__PURE__*/React.createElement(ConversationsMenu, null),
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
}, /*#__PURE__*/React.createElement(ConversationsMenu, null), snap.codeBlock ?
|
|
27
|
+
/*#__PURE__*/
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
React.createElement(SplitPane, {
|
|
30
|
+
split: "vertical",
|
|
31
|
+
defaultSize: '50vw',
|
|
32
|
+
onDragStarted: function onDragStarted() {
|
|
33
|
+
return setIsDragging(true);
|
|
34
|
+
},
|
|
35
|
+
onDragFinished: function onDragFinished() {
|
|
36
|
+
return setIsDragging(false);
|
|
37
|
+
},
|
|
38
|
+
primary: "second",
|
|
39
|
+
style: {
|
|
40
|
+
position: 'unset'
|
|
41
|
+
}
|
|
42
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
43
|
+
className: classnames(styles.msgBox)
|
|
44
|
+
}, children[0]), /*#__PURE__*/React.createElement("div", {
|
|
22
45
|
className: styles.taskBox
|
|
23
|
-
}, children[1]))
|
|
46
|
+
}, children[1])) : /*#__PURE__*/React.createElement("div", {
|
|
47
|
+
className: classnames(styles.msgBox, styles.msgBoxFull)
|
|
48
|
+
}, children[0]), isDragging && /*#__PURE__*/React.createElement("div", {
|
|
49
|
+
style: {
|
|
50
|
+
position: 'fixed',
|
|
51
|
+
top: 0,
|
|
52
|
+
left: 0,
|
|
53
|
+
right: 0,
|
|
54
|
+
bottom: 0,
|
|
55
|
+
zIndex: 9999,
|
|
56
|
+
cursor: 'col-resize' // 或 'row-resize' 用于水平分割
|
|
57
|
+
}
|
|
58
|
+
}));
|
|
24
59
|
}
|
|
25
60
|
export { SessionLayout };
|
|
@@ -60,7 +60,8 @@ var CodeEditor = function CodeEditor(_ref) {
|
|
|
60
60
|
_ref$onFullscreen = _ref.onFullscreen,
|
|
61
61
|
onFullscreen = _ref$onFullscreen === void 0 ? noop : _ref$onFullscreen,
|
|
62
62
|
_ref$showAI = _ref.showAI,
|
|
63
|
-
showAI = _ref$showAI === void 0 ? true : _ref$showAI
|
|
63
|
+
showAI = _ref$showAI === void 0 ? true : _ref$showAI,
|
|
64
|
+
style = _ref.style;
|
|
64
65
|
var umiLocation = useLocation();
|
|
65
66
|
var locale = useLocale();
|
|
66
67
|
var _useSiteData = useSiteData(),
|
|
@@ -399,7 +400,8 @@ var CodeEditor = function CodeEditor(_ref) {
|
|
|
399
400
|
setCode(source);
|
|
400
401
|
};
|
|
401
402
|
return /*#__PURE__*/React.createElement("div", {
|
|
402
|
-
className: styles.editor
|
|
403
|
+
className: styles.editor,
|
|
404
|
+
style: style
|
|
403
405
|
}, /*#__PURE__*/React.createElement(Toolbar, {
|
|
404
406
|
fileExtension: fileExtension,
|
|
405
407
|
sourceCode: code,
|
|
@@ -34,7 +34,9 @@ var CodeRunner = function CodeRunner(_ref) {
|
|
|
34
34
|
_ref$notFound = _ref.notFound,
|
|
35
35
|
notFound = _ref$notFound === void 0 ? /*#__PURE__*/React.createElement(NotFound, null) : _ref$notFound,
|
|
36
36
|
_ref$showAI = _ref.showAI,
|
|
37
|
-
showAI = _ref$showAI === void 0 ? true : _ref$showAI
|
|
37
|
+
showAI = _ref$showAI === void 0 ? true : _ref$showAI,
|
|
38
|
+
_ref$showEditor = _ref.showEditor,
|
|
39
|
+
showEditor = _ref$showEditor === void 0 ? true : _ref$showEditor;
|
|
38
40
|
var demoInfo = getDemoInfo(exampleTopics, topic, example, demo);
|
|
39
41
|
|
|
40
42
|
// 找不到,啥也别干了,404 页面
|
|
@@ -61,18 +63,13 @@ var CodeRunner = function CodeRunner(_ref) {
|
|
|
61
63
|
githubUrl: githubUrl
|
|
62
64
|
});
|
|
63
65
|
var exampleId = "".concat(topic, "_").concat(example, "_").concat(demo);
|
|
64
|
-
|
|
65
|
-
fallback: null
|
|
66
|
-
}, /*#__PURE__*/React.createElement(SplitPane, {
|
|
67
|
-
split: "vertical",
|
|
68
|
-
defaultSize: "".concat((1 - size) * 100, "%"),
|
|
69
|
-
minSize: 100
|
|
70
|
-
}, /*#__PURE__*/React.createElement(CodePreview, {
|
|
66
|
+
var codePreview = /*#__PURE__*/React.createElement(CodePreview, {
|
|
71
67
|
exampleId: exampleId,
|
|
72
68
|
error: error,
|
|
73
69
|
header: header,
|
|
74
70
|
isPlayground: isPlayground
|
|
75
|
-
})
|
|
71
|
+
});
|
|
72
|
+
var codeEditor = /*#__PURE__*/React.createElement(ClientOnly, null, /*#__PURE__*/React.createElement(CodeEditor, {
|
|
76
73
|
exampleId: exampleId,
|
|
77
74
|
source: source,
|
|
78
75
|
relativePath: relativePath,
|
|
@@ -83,7 +80,19 @@ var CodeRunner = function CodeRunner(_ref) {
|
|
|
83
80
|
onReady: noop,
|
|
84
81
|
playground: playground,
|
|
85
82
|
title: ic(title),
|
|
86
|
-
showAI: showAI
|
|
87
|
-
|
|
83
|
+
showAI: showAI,
|
|
84
|
+
style: {
|
|
85
|
+
display: showEditor ? 'block' : 'none'
|
|
86
|
+
}
|
|
87
|
+
}));
|
|
88
|
+
return /*#__PURE__*/React.createElement(InViewSuspense, {
|
|
89
|
+
fallback: null
|
|
90
|
+
},
|
|
91
|
+
// @ts-ignore
|
|
92
|
+
showEditor ? /*#__PURE__*/React.createElement(SplitPane, {
|
|
93
|
+
split: "vertical",
|
|
94
|
+
defaultSize: "".concat((1 - size) * 100, "%"),
|
|
95
|
+
minSize: 100
|
|
96
|
+
}, codePreview, codeEditor) : /*#__PURE__*/React.createElement(React.Fragment, null, codePreview, codeEditor));
|
|
88
97
|
};
|
|
89
98
|
export default CodeRunner;
|