@agentscope-ai/chat 1.1.8 → 1.1.9
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/lib/Accordion/Accordion.js +5 -3
- package/lib/Accordion/DeepThinking.js +1 -1
- package/lib/Accordion/SoftLightTitle.js +1 -1
- package/lib/Accordion/style.js +1 -3
- package/lib/ChatAnywhere/Input/index.js +3 -0
- package/lib/ChatAnywhere/hooks/types.d.ts +10 -0
- package/lib/DefaultCards/DeepThinking/index.d.ts +2 -0
- package/lib/DefaultCards/Images/index.js +3 -1
- package/lib/DefaultCards/Text/index.js +10 -9
- package/lib/DeviceAction/index.d.ts +33 -0
- package/lib/DeviceAction/index.js +77 -0
- package/lib/ImageGenerator/index.d.ts +12 -0
- package/lib/ImageGenerator/index.js +23 -12
- package/lib/ImageGenerator/style.js +3 -1
- package/lib/Markdown/CodeBlock.js +1 -1
- package/lib/Markdown/ImageOrMedia.js +5 -2
- package/lib/Markdown/Link.js +3 -3
- package/lib/Markdown/Markdown.js +5 -7
- package/lib/Markdown/index.js +6 -3
- package/lib/Markdown/style.js +1 -1
- package/lib/Markdown/useTyping.d.ts +4 -0
- package/lib/Markdown/useTyping.js +32 -0
- package/lib/Mermaid/index.js +29 -25
- package/lib/OperateCard/OperateCard.d.ts +31 -0
- package/lib/OperateCard/OperateCard.js +74 -0
- package/lib/OperateCard/index.d.ts +1 -0
- package/lib/OperateCard/index.js +1 -0
- package/lib/OperateCard/preset/Rag.d.ts +26 -0
- package/lib/OperateCard/preset/Rag.js +47 -0
- package/lib/OperateCard/preset/Thinking.d.ts +21 -0
- package/lib/OperateCard/preset/Thinking.js +24 -0
- package/lib/OperateCard/preset/TodoList.d.ts +24 -0
- package/lib/OperateCard/preset/TodoList.js +53 -0
- package/lib/OperateCard/preset/ToolCall.d.ts +27 -0
- package/lib/OperateCard/preset/ToolCall.js +44 -0
- package/lib/OperateCard/preset/WebSearch.d.ts +26 -0
- package/lib/OperateCard/preset/WebSearch.js +48 -0
- package/lib/OperateCard/preset/index.d.ts +5 -0
- package/lib/OperateCard/preset/index.js +5 -0
- package/lib/OperateCard/style.d.ts +2 -0
- package/lib/OperateCard/style.js +54 -0
- package/lib/Sender/ModeSelect/index.d.ts +1 -0
- package/lib/Sender/ModeSelect/index.js +4 -3
- package/lib/Sender/index.js +0 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +4 -2
- package/package.json +3 -3
- package/lib/DefaultCards/count/index.d.ts +0 -1
- package/lib/DefaultCards/count/index.js +0 -36
- package/lib/Markdown/hooks/index.d.ts +0 -0
- package/lib/Markdown/hooks/index.js +0 -0
- package/lib/Markdown/hooks/useTypedEffect.d.ts +0 -6
- package/lib/Markdown/hooks/useTypedEffect.js +0 -56
|
@@ -16,7 +16,7 @@ import BodyContent from "./BodyContent";
|
|
|
16
16
|
import SoftLightTitle from "./SoftLightTitle";
|
|
17
17
|
import useStyle from "./style";
|
|
18
18
|
import { useProviderContext } from "../Provider";
|
|
19
|
-
import { SparkCheckCircleFill, SparkErrorCircleFill, SparkDownLine, SparkUpLine, SparkLoadingLine } from '@agentscope-ai/icons';
|
|
19
|
+
import { SparkCheckCircleFill, SparkErrorCircleFill, SparkDownLine, SparkUpLine, SparkLoadingLine, SparkStopCircleLine } from '@agentscope-ai/icons';
|
|
20
20
|
import { Transition } from 'react-transition-group';
|
|
21
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
22
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -33,12 +33,14 @@ function Item(props) {
|
|
|
33
33
|
var icon = useMemo(function () {
|
|
34
34
|
if (props.icon) return props.icon;
|
|
35
35
|
if (props.status === 'generating') return /*#__PURE__*/_jsx(SparkLoadingLine, {
|
|
36
|
-
className: "".concat(prefixCls, "-icon-loading")
|
|
36
|
+
className: "".concat(prefixCls, "-icon-loading"),
|
|
37
|
+
spin: true
|
|
37
38
|
});
|
|
38
39
|
if (props.status === 'finished') return /*#__PURE__*/_jsx(SparkCheckCircleFill, {
|
|
39
40
|
className: "".concat(prefixCls, "-icon-success")
|
|
40
41
|
});
|
|
41
|
-
if (props.status === 'interrupted'
|
|
42
|
+
if (props.status === 'interrupted') return /*#__PURE__*/_jsx(SparkStopCircleLine, {});
|
|
43
|
+
if (props.status === 'error') return /*#__PURE__*/_jsx(SparkErrorCircleFill, {
|
|
42
44
|
className: "".concat(prefixCls, "-icon-error")
|
|
43
45
|
});
|
|
44
46
|
}, [props.status, props.icon]);
|
|
@@ -8,7 +8,7 @@ export default function (props) {
|
|
|
8
8
|
theme = _useProviderContext.theme,
|
|
9
9
|
getPrefixCls = _useProviderContext.getPrefixCls;
|
|
10
10
|
var prefixCls = getPrefixCls('accordion-deep-thinking');
|
|
11
|
-
var isDarkMode = theme.algorithm === AntdTheme.darkAlgorithm;
|
|
11
|
+
var isDarkMode = (theme === null || theme === void 0 ? void 0 : theme.algorithm) === AntdTheme.darkAlgorithm;
|
|
12
12
|
var icon = /*#__PURE__*/_jsx("img", {
|
|
13
13
|
style: {
|
|
14
14
|
display: 'block',
|
|
@@ -5,7 +5,7 @@ export default function (props) {
|
|
|
5
5
|
var _useProviderContext = useProviderContext(),
|
|
6
6
|
theme = _useProviderContext.theme,
|
|
7
7
|
getPrefixCls = _useProviderContext.getPrefixCls;
|
|
8
|
-
var isDarkMode = theme.algorithm === AntdTheme.darkAlgorithm;
|
|
8
|
+
var isDarkMode = (theme === null || theme === void 0 ? void 0 : theme.algorithm) === AntdTheme.darkAlgorithm;
|
|
9
9
|
var prefixCls = getPrefixCls('accordion-soft-light-title');
|
|
10
10
|
return /*#__PURE__*/_jsx("div", {
|
|
11
11
|
className: prefixCls,
|
package/lib/Accordion/style.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
var _templateObject;
|
|
2
2
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
3
3
|
import { createGlobalStyle } from "./..";
|
|
4
|
-
export default createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n.", "-accordion-group {\n width: 100%;\n\n svg {\n transform: scale(1.25);\n }\n \n .anticon-spin::before,\n .anticon-spin {\n animation-duration: 2s;\n }\n &-icon-success {\n color: ", ";\n }\n\n
|
|
4
|
+
export default createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n.", "-accordion-group {\n width: 100%;\n\n svg {\n transform: scale(1.25);\n }\n \n .anticon-spin::before,\n .anticon-spin {\n animation-duration: 2s;\n }\n &-icon-success {\n color: ", ";\n }\n\n \n\n\n @keyframes ", "-loading {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n\n &-icon-error {\n color: ", ";\n }\n\n &-header {\n display: flex;\n align-items: center;\n gap: 4px;\n color: ", ";\n padding: 6px 12px;\n font-size: 12px;\n cursor: pointer;\n line-height: 20px;\n background-color: ", ";\n\n &-arrow {\n display: flex;\n align-items: center;\n }\n\n &-close {\n border-radius: ", "px;\n border: 1px solid ", ";\n display: inline-flex;\n }\n\n &-icon {\n position: relative;\n display: flex;\n width: 16px;\n height: 16px;\n align-items: center;\n justify-content: center;\n font-size: 14px;\n\n &-line {\n &::before,\n &::after {\n content: '';\n position: absolute;\n width: 1px;\n height: 7px;\n background-color: ", ";\n left: 50%;\n transform: translateX(-50%);\n }\n\n &::before {\n top: -9px;\n }\n\n &::after {\n bottom: -9px;\n }\n }\n\n &-last::after {\n content: none;\n }\n\n &-first::before {\n content: none;\n }\n }\n }\n\n &-open {\n overflow: hidden;\n border-radius: 8px;\n border: 1px solid ", ";\n }\n\n &-body {\n margin: 8px;\n color: ", ";\n font-size: 12px;\n border-radius: 8px;\n overflow: hidden;\n\n .", "-accordion-group-header {\n background-color: transparent;\n }\n\n \n\n .", "-accordion-group-header-close,\n .", "-accordion-group-open {\n border: 0;\n }\n\n .", "-accordion-group-header-close {\n display: flex;\n }\n\n &-inline {\n padding: 8px 0;\n margin: 0;\n background-color: transparent;\n }\n\n > .", "-accordion-group {\n background-color: ", ";\n\n &-open {\n border-radius: 0;\n }\n }\n\n &-close {\n height: 0;\n padding: 0;\n margin: 0;\n }\n }\n}\n\n.", "-accordion-deep-thinking {\n font-size: 12px;\n color: ", ";\n text-align: left;\n white-space: pre-wrap;\n line-height: 20px;\n padding: 0 12px;\n border-left: 1px solid ", ";\n}\n\n.", "-accordion-soft-light-title {\n font-size: 12px;\n position: relative;\n display: inline-block;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n mask-image: linear-gradient(\n 270deg,\n rgba(231, 231, 237, 0.88) 20%,\n rgba(231, 231, 237, 0.5) 50%,\n rgba(255, 255, 255, 0.4) 52%,\n rgba(231, 231, 237, 0.5) 70%,\n rgba(231, 231, 237, 0.88) 80%\n );\n mask-size: 200% 100%;\n animation: softlight-text 3s linear infinite;\n}\n\n\n@keyframes softlight-text {\n 0% {\n mask-position: 100% 0;\n }\n\n 100% {\n mask-position: -100% 0;\n }\n}\n\n.", "-accordion-content-body {\n border: 1px solid ", ";\n border-radius: 8px;\n overflow: hidden;\n &-header {\n display: flex;\n height: 24px;\n align-items: center;\n justify-content: space-between;\n padding: 0 12px;\n border-bottom: 1px solid ", ";\n background-color: ", ";\n color: ", ";\n }\n\n &-body {\n background-color: ", ";\n }\n}\n"])), function (p) {
|
|
5
5
|
return p.prefix;
|
|
6
6
|
}, function (p) {
|
|
7
7
|
return p.theme.colorSuccess;
|
|
8
8
|
}, function (p) {
|
|
9
9
|
return p.prefix;
|
|
10
|
-
}, function (p) {
|
|
11
|
-
return p.prefix;
|
|
12
10
|
}, function (p) {
|
|
13
11
|
return p.theme.colorError;
|
|
14
12
|
}, function (p) {
|
|
@@ -72,6 +72,9 @@ export default /*#__PURE__*/forwardRef(function (_, ref) {
|
|
|
72
72
|
setInputContent: setContent
|
|
73
73
|
};
|
|
74
74
|
}, []);
|
|
75
|
+
useEffect(function () {
|
|
76
|
+
inputContext.setDisabled(onInput.disabled);
|
|
77
|
+
}, [onInput.disabled]);
|
|
75
78
|
if (onInput.hide) return null;
|
|
76
79
|
var handleFileChange = /*#__PURE__*/function () {
|
|
77
80
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(index, fileList) {
|
|
@@ -159,6 +159,11 @@ export interface IChatAnywhereConfigOnInput {
|
|
|
159
159
|
* @descriptionEn Placeholder text for the input field
|
|
160
160
|
*/
|
|
161
161
|
placeholder?: string;
|
|
162
|
+
/**
|
|
163
|
+
* @description 输入框是否禁用
|
|
164
|
+
* @descriptionEn Whether the input field is disabled
|
|
165
|
+
*/
|
|
166
|
+
disabled?: boolean;
|
|
162
167
|
}
|
|
163
168
|
export interface IChatAnywhereConfigOnUpload {
|
|
164
169
|
/**
|
|
@@ -196,6 +201,11 @@ export interface IChatAnywhereConfigOnUpload {
|
|
|
196
201
|
* @descriptionEn Icon for the upload button
|
|
197
202
|
*/
|
|
198
203
|
icon?: string | React.ReactElement;
|
|
204
|
+
/**
|
|
205
|
+
* @description 是否禁用上传组件
|
|
206
|
+
* @descriptionEn Whether to disable the upload component
|
|
207
|
+
*/
|
|
208
|
+
disabled?: boolean;
|
|
199
209
|
}
|
|
200
210
|
export interface IChatAnywhereConfig {
|
|
201
211
|
/**
|
|
@@ -5,7 +5,9 @@ import { Space, Image as AntdImage, ConfigProvider } from 'antd';
|
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
6
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
7
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
-
var useStyle = createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n.", "-bubble-image {\n border-radius: 8px;\n overflow: hidden;\n\n .", "-image-img {\n object-fit: cover;\n }\n\n .", "-image-mask-info {\n span {\n margin-inline-end: 0 !important;\n }\n }\n}\n"])), function (p) {
|
|
8
|
+
var useStyle = createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n.", "-bubble-image {\n border-radius: 8px;\n overflow: hidden;\n\n .", "-image {\n display: block;\n }\n .", "-image-img {\n object-fit: cover;\n }\n\n .", "-image-mask-info {\n span {\n margin-inline-end: 0 !important;\n }\n }\n}\n"])), function (p) {
|
|
9
|
+
return p.prefix;
|
|
10
|
+
}, function (p) {
|
|
9
11
|
return p.prefix;
|
|
10
12
|
}, function (p) {
|
|
11
13
|
return p.prefix;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1
7
|
import React from 'react';
|
|
2
8
|
import { Markdown } from "../..";
|
|
3
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
10
|
export default function (props) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
typing: props.data.typing,
|
|
10
|
-
citations: props.data.citations,
|
|
11
|
-
citationsMap: props.data.citationsMap,
|
|
12
|
-
className: props.data.className
|
|
13
|
-
});
|
|
11
|
+
var cursor = props.data.msgStatus === 'generating';
|
|
12
|
+
return /*#__PURE__*/_jsx(Markdown, _objectSpread({
|
|
13
|
+
cursor: cursor
|
|
14
|
+
}, props.data));
|
|
14
15
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface IDeviceActionProps {
|
|
2
|
+
/**
|
|
3
|
+
* @description 时间
|
|
4
|
+
* @descriptionEn Time
|
|
5
|
+
* @default ''
|
|
6
|
+
*/
|
|
7
|
+
time?: string;
|
|
8
|
+
/**
|
|
9
|
+
* @description 动作
|
|
10
|
+
* @descriptionEn Action
|
|
11
|
+
* @default ''
|
|
12
|
+
*/
|
|
13
|
+
action: 'Click' | 'Swipe' | 'Type' | 'Back' | 'Home' | 'Done' | 'Wait' | 'call_user';
|
|
14
|
+
/**
|
|
15
|
+
* @description 动作名称,通常不用传入,会根据 action 自动生成
|
|
16
|
+
* @descriptionEn Action Name, usually not passed in, will be generated automatically based on action
|
|
17
|
+
* @default ''
|
|
18
|
+
*/
|
|
19
|
+
actionName?: string;
|
|
20
|
+
/**
|
|
21
|
+
* @description 描述
|
|
22
|
+
* @descriptionEn Description
|
|
23
|
+
* @default ''
|
|
24
|
+
*/
|
|
25
|
+
description: string;
|
|
26
|
+
/**
|
|
27
|
+
* @description 操作截图
|
|
28
|
+
* @descriptionEn Operation Screenshot
|
|
29
|
+
* @default ''
|
|
30
|
+
*/
|
|
31
|
+
image?: string;
|
|
32
|
+
}
|
|
33
|
+
export default function (props: IDeviceActionProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { OperateCard, useProviderContext } from "./..";
|
|
2
|
+
import { SparkCheckCircleLine, SparkEditLine, SparkHomeLine, SparkLoadingLine, SparkSortLine, SparkTargetLine, SparkUndoLine } from '@agentscope-ai/icons';
|
|
3
|
+
import { ConfigProvider, Image } from 'antd';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
var actionMap = {
|
|
7
|
+
Click: {
|
|
8
|
+
name: '点击',
|
|
9
|
+
icon: /*#__PURE__*/_jsx(SparkTargetLine, {})
|
|
10
|
+
},
|
|
11
|
+
Swipe: {
|
|
12
|
+
name: '滑动',
|
|
13
|
+
icon: /*#__PURE__*/_jsx(SparkSortLine, {})
|
|
14
|
+
},
|
|
15
|
+
Type: {
|
|
16
|
+
name: '输入',
|
|
17
|
+
icon: /*#__PURE__*/_jsx(SparkEditLine, {})
|
|
18
|
+
},
|
|
19
|
+
Back: {
|
|
20
|
+
name: '返回',
|
|
21
|
+
icon: /*#__PURE__*/_jsx(SparkUndoLine, {})
|
|
22
|
+
},
|
|
23
|
+
Home: {
|
|
24
|
+
name: '主页',
|
|
25
|
+
icon: /*#__PURE__*/_jsx(SparkHomeLine, {})
|
|
26
|
+
},
|
|
27
|
+
Done: {
|
|
28
|
+
name: '完成',
|
|
29
|
+
icon: /*#__PURE__*/_jsx(SparkCheckCircleLine, {})
|
|
30
|
+
},
|
|
31
|
+
Wait: {
|
|
32
|
+
name: '等待',
|
|
33
|
+
icon: /*#__PURE__*/_jsx(SparkLoadingLine, {})
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export default function (props) {
|
|
37
|
+
var _useProviderContext = useProviderContext(),
|
|
38
|
+
getPrefixCls = _useProviderContext.getPrefixCls;
|
|
39
|
+
var prefixCls = getPrefixCls('operate-card');
|
|
40
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
41
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
42
|
+
className: "".concat(prefixCls, "-device-action-time"),
|
|
43
|
+
children: props.time
|
|
44
|
+
}), /*#__PURE__*/_jsx(OperateCard, {
|
|
45
|
+
header: {
|
|
46
|
+
className: "".concat(prefixCls, "-device-action"),
|
|
47
|
+
icon: actionMap[props.action].icon,
|
|
48
|
+
title: /*#__PURE__*/_jsxs("div", {
|
|
49
|
+
className: "".concat(prefixCls, "-device-action-content"),
|
|
50
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
51
|
+
className: "".concat(prefixCls, "-device-action-description"),
|
|
52
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
53
|
+
children: props.actionName || actionMap[props.action].name
|
|
54
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
55
|
+
children: props.description
|
|
56
|
+
})]
|
|
57
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
58
|
+
className: "".concat(prefixCls, "-device-action-image"),
|
|
59
|
+
children: /*#__PURE__*/_jsx(ConfigProvider, {
|
|
60
|
+
locale: {
|
|
61
|
+
Image: {
|
|
62
|
+
preview: ''
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
children: /*#__PURE__*/_jsx(Image, {
|
|
66
|
+
src: props.image,
|
|
67
|
+
alt: props.description,
|
|
68
|
+
width: '100%',
|
|
69
|
+
height: '100%'
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
})]
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
})]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -36,6 +36,18 @@ export interface IImageGeneratorProps {
|
|
|
36
36
|
* @default null
|
|
37
37
|
*/
|
|
38
38
|
skeleton?: ReactNode;
|
|
39
|
+
/**
|
|
40
|
+
* @description 自定义骨架屏组件的加载态提示
|
|
41
|
+
* @descriptionEn Custom skeleton screen component prompt text
|
|
42
|
+
* @default 'Painting...'
|
|
43
|
+
*/
|
|
44
|
+
skeletonText?: string;
|
|
45
|
+
/**
|
|
46
|
+
* @description 是否为块级元素,使得图片宽高比为 width / height
|
|
47
|
+
* @descriptionEn Whether to be a block element, make the image width / height ratio
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
50
|
+
block?: boolean;
|
|
39
51
|
}
|
|
40
52
|
declare const ImageGenerator: React.FC<IImageGeneratorProps>;
|
|
41
53
|
export default ImageGenerator;
|
|
@@ -12,7 +12,9 @@ var ImageGenerator = function ImageGenerator(props) {
|
|
|
12
12
|
var _useProviderContext = useProviderContext(),
|
|
13
13
|
getPrefixCls = _useProviderContext.getPrefixCls;
|
|
14
14
|
var prefixCls = getPrefixCls('image-generator');
|
|
15
|
-
var
|
|
15
|
+
var block = props.block,
|
|
16
|
+
skeletonText = props.skeletonText,
|
|
17
|
+
_props$width = props.width,
|
|
16
18
|
width = _props$width === void 0 ? 320 : _props$width,
|
|
17
19
|
_props$height = props.height,
|
|
18
20
|
height = _props$height === void 0 ? 320 : _props$height,
|
|
@@ -24,19 +26,31 @@ var ImageGenerator = function ImageGenerator(props) {
|
|
|
24
26
|
var skeleton = props.skeleton || /*#__PURE__*/_jsxs("div", {
|
|
25
27
|
className: "".concat(prefixCls, "-default-skeleton"),
|
|
26
28
|
style: {
|
|
27
|
-
width:
|
|
28
|
-
height:
|
|
29
|
+
width: '100%',
|
|
30
|
+
height: '100%'
|
|
29
31
|
},
|
|
30
32
|
children: [/*#__PURE__*/_jsx("img", {
|
|
31
33
|
className: "".concat(prefixCls, "-default-skeleton-bg"),
|
|
32
34
|
src: "https://img.alicdn.com/imgextra/i2/O1CN01jwLfwV1hPiHfJjQXM_!!6000000004270-2-tps-1155-763.png",
|
|
33
35
|
alt: ""
|
|
34
|
-
}), /*#__PURE__*/
|
|
35
|
-
className: "".concat(prefixCls, "-default-skeleton-
|
|
36
|
-
|
|
36
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
37
|
+
className: "".concat(prefixCls, "-default-skeleton-content"),
|
|
38
|
+
children: [/*#__PURE__*/_jsx("img", {
|
|
39
|
+
className: "".concat(prefixCls, "-default-skeleton-icon"),
|
|
40
|
+
src: "https://img.alicdn.com/imgextra/i2/O1CN01M1X8yM1MWUC7u3Go5_!!6000000001442-54-tps-72-72.apng"
|
|
41
|
+
}), skeletonText && /*#__PURE__*/_jsx("div", {
|
|
42
|
+
className: "".concat(prefixCls, "-default-skeleton-text"),
|
|
43
|
+
children: skeletonText
|
|
44
|
+
})]
|
|
37
45
|
})]
|
|
38
46
|
});
|
|
39
47
|
var loading = !src;
|
|
48
|
+
var size = block ? {
|
|
49
|
+
aspectRatio: "".concat(width, "/").concat(height)
|
|
50
|
+
} : {
|
|
51
|
+
width: width,
|
|
52
|
+
height: height
|
|
53
|
+
};
|
|
40
54
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
41
55
|
children: [/*#__PURE__*/_jsx(Style, {}), /*#__PURE__*/_jsxs("div", {
|
|
42
56
|
className: prefixCls,
|
|
@@ -52,10 +66,7 @@ var ImageGenerator = function ImageGenerator(props) {
|
|
|
52
66
|
}) : doneText]
|
|
53
67
|
}), /*#__PURE__*/_jsx("div", {
|
|
54
68
|
className: "".concat(prefixCls, "-wrapper"),
|
|
55
|
-
style:
|
|
56
|
-
width: width,
|
|
57
|
-
height: height
|
|
58
|
-
},
|
|
69
|
+
style: size,
|
|
59
70
|
children: loading ? skeleton : /*#__PURE__*/_jsx(ConfigProvider, {
|
|
60
71
|
locale: {
|
|
61
72
|
Image: {
|
|
@@ -63,8 +74,8 @@ var ImageGenerator = function ImageGenerator(props) {
|
|
|
63
74
|
}
|
|
64
75
|
},
|
|
65
76
|
children: /*#__PURE__*/_jsx(Image, {
|
|
66
|
-
|
|
67
|
-
|
|
77
|
+
width: '100%',
|
|
78
|
+
height: '100%',
|
|
68
79
|
src: src
|
|
69
80
|
})
|
|
70
81
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var _templateObject;
|
|
2
2
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
3
3
|
import { createGlobalStyle } from "./..";
|
|
4
|
-
export default createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n.", "-image-generator {\n\n .", "-image {\n border-radius: 8px;\n filter: blur(20px);\n animation: ", "clearBlur 1s ease forwards;\n overflow: hidden;\n }\n\n\n &-wrapper {\n overflow: hidden;\n }\n\n\n &-text {\n position: relative;\n display: flex;\n gap: 8px;\n height: 40px;\n align-items: center;\n font-size: 14px;\n line-height: 26px;\n color: ", ";\n\n\n &-success {\n color: ", ";\n font-size: 20px;\n }\n }\n\n &-default-skeleton {\n position: relative;\n overflow: hidden;\n border-radius: 8px;\n display: flex;\n align-items: center;\n justify-content: center;\n\n\n &-bg {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%) rotate(0deg);\n width: 300%;\n height: 300%;\n object-fit: cover;\n animation: ", "spin 6s linear infinite;\n pointer-events: none;\n }\n\n &-icon {\n width: 32px;\n height: 32px;\n z-index: 1;\n }\n }\n}\n\n\n\n@keyframes ", "clearBlur {\n from {\n filter: blur(20px);\n }\n to {\n filter: blur(0);\n }\n}\n\n@keyframes ", "spin {\n from {\n transform: translate(-50%, -50%) rotate(0deg);\n }\n to {\n transform: translate(-50%, -50%) rotate(360deg);\n }\n}\n"])), function (p) {
|
|
4
|
+
export default createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n.", "-image-generator {\n\n .", "-image {\n border-radius: 8px;\n filter: blur(20px);\n animation: ", "clearBlur 1s ease forwards;\n overflow: hidden;\n }\n\n\n &-wrapper {\n overflow: hidden;\n }\n\n\n &-text {\n position: relative;\n display: flex;\n gap: 8px;\n height: 40px;\n align-items: center;\n font-size: 14px;\n line-height: 26px;\n color: ", ";\n\n\n &-success {\n color: ", ";\n font-size: 20px;\n }\n }\n\n &-default-skeleton {\n position: relative;\n overflow: hidden;\n border-radius: 8px;\n display: flex;\n align-items: center;\n justify-content: center;\n\n\n &-bg {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%) rotate(0deg);\n width: 300%;\n height: 300%;\n object-fit: cover;\n animation: ", "spin 6s linear infinite;\n pointer-events: none;\n }\n\n &-icon {\n width: 32px;\n height: 32px;\n } \n\n &-content {\n display: flex;\n flex-direction: column;\n gap: 4px;\n align-items: center;\n justify-content: center;\n z-index: 1;\n \n }\n\n &-text {\n margin-top: 8px;\n font-size: 14px;\n color: ", ";\n }\n }\n}\n\n\n\n@keyframes ", "clearBlur {\n from {\n filter: blur(20px);\n }\n to {\n filter: blur(0);\n }\n}\n\n@keyframes ", "spin {\n from {\n transform: translate(-50%, -50%) rotate(0deg);\n }\n to {\n transform: translate(-50%, -50%) rotate(360deg);\n }\n}\n"])), function (p) {
|
|
5
5
|
return p.prefix;
|
|
6
6
|
}, function (p) {
|
|
7
7
|
return p.prefix;
|
|
@@ -13,6 +13,8 @@ export default createGlobalStyle(_templateObject || (_templateObject = _taggedTe
|
|
|
13
13
|
return p.theme.colorSuccess;
|
|
14
14
|
}, function (p) {
|
|
15
15
|
return p.prefix;
|
|
16
|
+
}, function (p) {
|
|
17
|
+
return p.theme.colorBgBase;
|
|
16
18
|
}, function (p) {
|
|
17
19
|
return p.prefix;
|
|
18
20
|
}, function (p) {
|
|
@@ -45,7 +45,7 @@ var CodeBlock = function CodeBlock(_ref) {
|
|
|
45
45
|
var _useProviderContext = useProviderContext(),
|
|
46
46
|
getPrefixCls = _useProviderContext.getPrefixCls,
|
|
47
47
|
theme = _useProviderContext.theme;
|
|
48
|
-
var isDarkMode = theme.algorithm === AntdTheme.darkAlgorithm;
|
|
48
|
+
var isDarkMode = (theme === null || theme === void 0 ? void 0 : theme.algorithm) === AntdTheme.darkAlgorithm;
|
|
49
49
|
var _useState = useState(false),
|
|
50
50
|
_useState2 = _slicedToArray(_useState, 2),
|
|
51
51
|
copied = _useState2[0],
|
|
@@ -70,8 +70,11 @@ function Video(props) {
|
|
|
70
70
|
return setOpen(true);
|
|
71
71
|
},
|
|
72
72
|
className: prefixCls,
|
|
73
|
-
children: /*#__PURE__*/_jsx(
|
|
74
|
-
className: "".concat(prefixCls, "-
|
|
73
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
74
|
+
className: "".concat(prefixCls, "-poster"),
|
|
75
|
+
children: /*#__PURE__*/_jsx(SparkPlayCircleFill, {
|
|
76
|
+
className: "".concat(prefixCls, "-play")
|
|
77
|
+
})
|
|
75
78
|
})
|
|
76
79
|
}), /*#__PURE__*/_jsx(Modal, {
|
|
77
80
|
closeIcon: /*#__PURE__*/_jsx("a", {
|
package/lib/Markdown/Link.js
CHANGED
|
@@ -18,9 +18,9 @@ var Link = function Link(props) {
|
|
|
18
18
|
target = props.target,
|
|
19
19
|
citationsData = props.citationsData,
|
|
20
20
|
children = props.children;
|
|
21
|
-
if (children === '
|
|
22
|
-
if (href === '
|
|
23
|
-
if (href === '
|
|
21
|
+
if (children === '.' && (href === '.' || href === '_')) {
|
|
22
|
+
if (href === '.') return /*#__PURE__*/_jsx(Dot, {});
|
|
23
|
+
if (href === '_') return /*#__PURE__*/_jsx(Underline, {});
|
|
24
24
|
}
|
|
25
25
|
var match = href === null || href === void 0 || (_href$startsWith = href.startsWith) === null || _href$startsWith === void 0 ? void 0 : _href$startsWith.call(href, 'citation-');
|
|
26
26
|
if (match) {
|
package/lib/Markdown/Markdown.js
CHANGED
|
@@ -47,8 +47,8 @@ var Markdown = /*#__PURE__*/memo(function (_ref) {
|
|
|
47
47
|
|
|
48
48
|
// 计算缓存键
|
|
49
49
|
var cacheKey = useMemo(function () {
|
|
50
|
-
return "".concat(children, "-").concat(enableLatex, "-").concat(enableCustomFootnotes, "-").concat(Object.keys(citationsData).length);
|
|
51
|
-
}, [children, enableLatex, enableCustomFootnotes, citationsData]);
|
|
50
|
+
return "".concat(children, "-").concat(cursor, "-").concat(enableLatex, "-").concat(enableCustomFootnotes, "-").concat(Object.keys(citationsData).length);
|
|
51
|
+
}, [children, cursor, enableLatex, enableCustomFootnotes, citationsData]);
|
|
52
52
|
|
|
53
53
|
// 处理内容并利用缓存避免重复计算
|
|
54
54
|
var escapedContent = useMemo(function () {
|
|
@@ -65,16 +65,14 @@ var Markdown = /*#__PURE__*/memo(function (_ref) {
|
|
|
65
65
|
} else {
|
|
66
66
|
processedContent = fixMarkdownBold(children);
|
|
67
67
|
}
|
|
68
|
-
|
|
69
|
-
// 缓存处理结果
|
|
70
|
-
addToCache(cacheKey, processedContent);
|
|
71
68
|
if (cursor) {
|
|
72
69
|
if (typeof cursor === 'string') {
|
|
73
|
-
processedContent = processedContent + " [
|
|
70
|
+
processedContent = processedContent + " [.](".concat(cursor === 'dot' ? '.' : '_', ")");
|
|
74
71
|
} else {
|
|
75
|
-
processedContent = processedContent + " [
|
|
72
|
+
processedContent = processedContent + " [.](.)";
|
|
76
73
|
}
|
|
77
74
|
}
|
|
75
|
+
addToCache(cacheKey, processedContent);
|
|
78
76
|
return processedContent;
|
|
79
77
|
}, [cacheKey, children, cursor, enableLatex, enableCustomFootnotes, citationsData]);
|
|
80
78
|
|
package/lib/Markdown/index.js
CHANGED
|
@@ -3,16 +3,19 @@ import Markdown from "./Markdown";
|
|
|
3
3
|
import useStyle from "./style";
|
|
4
4
|
import { useGlobalContext, useProviderContext } from "./..";
|
|
5
5
|
import classnames from 'classnames';
|
|
6
|
+
import { useTyping } from "./useTyping";
|
|
6
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
8
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
8
9
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
10
|
function MarkdownComponent(props) {
|
|
10
11
|
var _useGlobalContext = useGlobalContext(),
|
|
11
12
|
markdown = _useGlobalContext.markdown;
|
|
12
|
-
var _props$
|
|
13
|
-
content = _props$content === void 0 ? '' : _props$content,
|
|
14
|
-
_props$raw = props.raw,
|
|
13
|
+
var _props$raw = props.raw,
|
|
15
14
|
raw = _props$raw === void 0 ? false : _props$raw;
|
|
15
|
+
var content = useTyping({
|
|
16
|
+
content: props.content || '',
|
|
17
|
+
typing: props.typing
|
|
18
|
+
});
|
|
16
19
|
var baseFontSize = props.baseFontSize || (markdown === null || markdown === void 0 ? void 0 : markdown.baseFontSize) || 14;
|
|
17
20
|
var baseLineHeight = props.baseLineHeight || 1.7;
|
|
18
21
|
var Style = useStyle();
|
package/lib/Markdown/style.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var _templateObject;
|
|
2
2
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
3
3
|
import { createGlobalStyle } from "./..";
|
|
4
|
-
export default createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n.", "-markdown {\n color: inherit;\n\n .katex-display {\n font-size: 1.3em;\n }\n\n .katex-html {\n display: none;\n }\n\n .katex-error {\n color: inherit !important;\n }\n\n .cm-gutter-lint {\n width: 0;\n }\n\n .cm-line {\n background-color: transparent !important;\n }\n\n .cm-activeLineGutter {\n background-color: transparent !important;\n color: inherit !important;\n }\n\n .\u037C1.cm-focused {\n outline: 0 !important;\n }\n\n mstyle[mathcolor=\"#cc0000\"] {\n opacity: 0;\n }\n\n ol, ul {\n padding-left: 30px;\n }\n\n blockquote {\n padding-inline: 0.6em 0;\n padding-block: 0;\n margin: 1em 0;\n border-inline-start: 4px solid rgba(100, 100, 100, 0.2);\n opacity: 0.85;\n }\n\n &-cursor {}\n\n figure {\n margin: 0;\n }\n\n figure img {\n display: block;\n cursor: pointer;\n }\n\n code .", "-markdown-cursor,\n pre .", "-markdown-cursor,\n table .", "-markdown-cursor {\n display: none;\n }\n\n @keyframes typography-cursor {\n 0% {\n opacity: 1;\n }\n\n 100% {\n opacity: 0;\n }\n }\n\n code {\n font-size: 0.8571428571428571em;\n border: 0 !important;\n }\n\n pre code {\n font-size: 0.8571428571428571em;\n }\n\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n margin-top: 0.5714285714285714em !important;\n margin-bottom: 0.5714285714285714em !important;\n font-weight: 500;\n line-height: 1.7777;\n color: inherit !important;\n }\n\n p {\n margin-top: 0.5714285714285714em !important;\n margin-bottom: 0.5714285714285714em !important;\n }\n\n h1 {\n font-size: 1.2857142857142858em;\n }\n\n h2 {\n font-size: 1.1428571428571428em;\n }\n\n h3 {\n font-size: 1em;\n }\n\n h4 {\n font-size: 1em;\n }\n\n h5 {\n font-size: 1em;\n }\n\n h6 {\n font-size: 1em;\n }\n\n hr {\n border-color: ", ";\n border-style: solid;\n border-width: 1px 0 0 0;\n margin: 1em 0;\n }\n\n table {\n border-collapse: collapse;\n display: block;\n width: max-content;\n max-width: 100%;\n overflow: auto;\n }\n\n table th {\n background: ", ";\n text-align: left;\n }\n\n table td,\n table th {\n padding: 0.75em 1.5em;\n border: 1px solid ", ";\n white-space: pre;\n }\n\n .", "-image {\n
|
|
4
|
+
export default createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n.", "-markdown {\n color: inherit;\n\n .katex-display {\n font-size: 1.3em;\n }\n\n .katex-html {\n display: none;\n }\n\n .katex-error {\n color: inherit !important;\n }\n\n .cm-gutter-lint {\n width: 0;\n }\n\n .cm-line {\n background-color: transparent !important;\n }\n\n .cm-activeLineGutter {\n background-color: transparent !important;\n color: inherit !important;\n }\n\n .\u037C1.cm-focused {\n outline: 0 !important;\n }\n\n mstyle[mathcolor=\"#cc0000\"] {\n opacity: 0;\n }\n\n ol, ul {\n padding-left: 30px;\n }\n\n blockquote {\n padding-inline: 0.6em 0;\n padding-block: 0;\n margin: 1em 0;\n border-inline-start: 4px solid rgba(100, 100, 100, 0.2);\n opacity: 0.85;\n }\n\n &-cursor {}\n\n figure {\n margin: 0;\n }\n\n figure img {\n display: block;\n cursor: pointer;\n }\n\n code .", "-markdown-cursor,\n pre .", "-markdown-cursor,\n table .", "-markdown-cursor {\n display: none;\n }\n\n @keyframes typography-cursor {\n 0% {\n opacity: 1;\n }\n\n 100% {\n opacity: 0;\n }\n }\n\n code {\n font-size: 0.8571428571428571em;\n border: 0 !important;\n }\n\n pre code {\n font-size: 0.8571428571428571em;\n }\n\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n margin-top: 0.5714285714285714em !important;\n margin-bottom: 0.5714285714285714em !important;\n font-weight: 500;\n line-height: 1.7777;\n color: inherit !important;\n }\n\n p {\n margin-top: 0.5714285714285714em !important;\n margin-bottom: 0.5714285714285714em !important;\n }\n\n h1 {\n font-size: 1.2857142857142858em;\n }\n\n h2 {\n font-size: 1.1428571428571428em;\n }\n\n h3 {\n font-size: 1em;\n }\n\n h4 {\n font-size: 1em;\n }\n\n h5 {\n font-size: 1em;\n }\n\n h6 {\n font-size: 1em;\n }\n\n hr {\n border-color: ", ";\n border-style: solid;\n border-width: 1px 0 0 0;\n margin: 1em 0;\n }\n\n table {\n border-collapse: collapse;\n display: block;\n width: max-content;\n max-width: 100%;\n overflow: auto;\n }\n\n table th {\n background: ", ";\n text-align: left;\n }\n\n table td,\n table th {\n padding: 0.75em 1.5em;\n border: 1px solid ", ";\n white-space: pre;\n }\n\n .", "-image {\n max-width: 480px;\n }\n\n}\n\n.", "-markdown-video {\n position: relative;\n cursor: pointer;\n \n &-poster {\n display: flex;\n align-items: center;\n justify-content: center;\n max-width: 480px;\n background-color: #000;\n border-radius: 8px;\n padding: 100px 0;\n }\n\n &-play {\n color: #ccc;\n font-size: 30px;\n }\n}\n\n\n.", "-markdown .", "-image {\n cursor: pointer;\n overflow: hidden;\n border-radius: 8px;\n}\n\n.", "-markdown > *:last-child {\n margin-bottom: 0 !important;\n}\n\n.", "-markdown > *:first-child {\n margin-top: 0 !important;\n}\n\n@keyframes fade-in {\n 0% {\n opacity: 0;\n }\n\n 100% {\n opacity: 1;\n }\n}\n\n\n.animate-fade-in {\n animation: fade-in 1s;\n}\n\n"])), function (p) {
|
|
5
5
|
return p.prefix;
|
|
6
6
|
}, function (p) {
|
|
7
7
|
return p.prefix;
|
|
@@ -0,0 +1,32 @@
|
|
|
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; }
|
|
7
|
+
import { useEffect, useRef, useState } from "react";
|
|
8
|
+
export var useTyping = function useTyping(_ref) {
|
|
9
|
+
var content = _ref.content,
|
|
10
|
+
typing = _ref.typing;
|
|
11
|
+
var _useState = useState(0),
|
|
12
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
13
|
+
index = _useState2[0],
|
|
14
|
+
setIndex = _useState2[1];
|
|
15
|
+
var timer = useRef();
|
|
16
|
+
useEffect(function () {
|
|
17
|
+
if (typing) {
|
|
18
|
+
timer.current = setInterval(function () {
|
|
19
|
+
setIndex(function (v) {
|
|
20
|
+
return v + 1;
|
|
21
|
+
});
|
|
22
|
+
}, 5);
|
|
23
|
+
} else {
|
|
24
|
+
timer.current && clearInterval(timer.current);
|
|
25
|
+
}
|
|
26
|
+
return function () {
|
|
27
|
+
return clearInterval(timer.current);
|
|
28
|
+
};
|
|
29
|
+
}, [typing]);
|
|
30
|
+
if (!typing) return content;
|
|
31
|
+
return content.slice(0, index);
|
|
32
|
+
};
|
package/lib/Mermaid/index.js
CHANGED
|
@@ -26,28 +26,32 @@ var useStyle = createGlobalStyle(_templateObject || (_templateObject = _taggedTe
|
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
// 懒加载 Mermaid 实例
|
|
29
|
-
var mermaidPromise
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}))
|
|
29
|
+
var mermaidPromise;
|
|
30
|
+
var genMermaidPromise = /*#__PURE__*/function () {
|
|
31
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
32
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
33
|
+
while (1) switch (_context.prev = _context.next) {
|
|
34
|
+
case 0:
|
|
35
|
+
if (!mermaidPromise) {
|
|
36
|
+
_context.next = 2;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
return _context.abrupt("return", mermaidPromise);
|
|
40
|
+
case 2:
|
|
41
|
+
mermaidPromise = import('mermaid').then(function (module) {
|
|
42
|
+
return module.default;
|
|
43
|
+
});
|
|
44
|
+
return _context.abrupt("return", mermaidPromise);
|
|
45
|
+
case 4:
|
|
46
|
+
case "end":
|
|
47
|
+
return _context.stop();
|
|
48
|
+
}
|
|
49
|
+
}, _callee);
|
|
50
|
+
}));
|
|
51
|
+
return function genMermaidPromise() {
|
|
52
|
+
return _ref.apply(this, arguments);
|
|
53
|
+
};
|
|
54
|
+
}();
|
|
51
55
|
export default function Mermaid(props) {
|
|
52
56
|
var content = props.content,
|
|
53
57
|
width = props.width,
|
|
@@ -59,11 +63,11 @@ export default function Mermaid(props) {
|
|
|
59
63
|
var prefixCls = getPrefixCls('mermaid');
|
|
60
64
|
var mermaidConfig = useMemo(function () {
|
|
61
65
|
return {
|
|
62
|
-
theme: theme.algorithm === AntdTheme.darkAlgorithm ? 'dark' : 'default',
|
|
66
|
+
theme: (theme === null || theme === void 0 ? void 0 : theme.algorithm) === AntdTheme.darkAlgorithm ? 'dark' : 'default',
|
|
63
67
|
securityLevel: 'loose',
|
|
64
68
|
startOnLoad: false
|
|
65
69
|
};
|
|
66
|
-
}, [theme.algorithm, theme.token.fontFamily]);
|
|
70
|
+
}, [theme === null || theme === void 0 ? void 0 : theme.algorithm, theme === null || theme === void 0 ? void 0 : theme.token.fontFamily]);
|
|
67
71
|
var _useState = useState(''),
|
|
68
72
|
_useState2 = _slicedToArray(_useState, 2),
|
|
69
73
|
renderedContent = _useState2[0],
|
|
@@ -81,7 +85,7 @@ export default function Mermaid(props) {
|
|
|
81
85
|
case 0:
|
|
82
86
|
_context2.prev = 0;
|
|
83
87
|
_context2.next = 3;
|
|
84
|
-
return
|
|
88
|
+
return genMermaidPromise();
|
|
85
89
|
case 3:
|
|
86
90
|
mermaidInstance = _context2.sent;
|
|
87
91
|
if (mermaidInstance) {
|