@lobehub/ui 2.1.5 → 2.1.7
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/FormModal/FormModal.js +4 -4
- package/es/FormModal/type.d.ts +1 -1
- package/es/Markdown/Markdown.js +44 -35
- package/es/Markdown/SyntaxMarkdown/index.d.ts +1 -2
- package/es/Markdown/SyntaxMarkdown/index.js +19 -90
- package/es/Markdown/components/MarkdownProvider.d.ts +9 -0
- package/es/Markdown/components/MarkdownProvider.js +17 -0
- package/es/Markdown/type.d.ts +5 -4
- package/es/Modal/Modal.js +4 -4
- package/es/chat/MessageModal/MessageModal.js +1 -1
- package/es/hooks/useMarkdown/index.d.ts +4 -14
- package/es/hooks/useMarkdown/index.js +4 -226
- package/es/hooks/useMarkdown/useMarkdownComponents.d.ts +2 -0
- package/es/hooks/useMarkdown/useMarkdownComponents.js +95 -0
- package/es/hooks/useMarkdown/useMarkdownContent.d.ts +1 -0
- package/es/hooks/useMarkdown/useMarkdownContent.js +64 -0
- package/es/hooks/useMarkdown/useMarkdownRehypePlugins.d.ts +2 -0
- package/es/hooks/useMarkdown/useMarkdownRehypePlugins.js +32 -0
- package/es/hooks/useMarkdown/useMarkdownRemarkPlugins.d.ts +2 -0
- package/es/hooks/useMarkdown/useMarkdownRemarkPlugins.js +33 -0
- package/es/hooks/useMarkdown/utils.d.ts +0 -24
- package/es/hooks/useMarkdown/utils.js +0 -52
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
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); }
|
|
4
|
-
var _excluded = ["classNames", "className", "style", "closable", "styles", "allowFullscreen", "title", "afterOpenChange", "width", "onCancel", "centered", "open", "afterClose", "
|
|
4
|
+
var _excluded = ["classNames", "className", "style", "closable", "styles", "allowFullscreen", "title", "afterOpenChange", "width", "onCancel", "centered", "open", "afterClose", "destroyOnHidden", "closeIcon", "paddings", "height", "enableResponsive", "zIndex", "mask", "getContainer", "keyboard", "focusTriggerAfterClose", "forceRender", "loading", "footer", "submitButtonProps", "submitLoading", "onFinish", "submitText", "variant", "gap", "onSubmit", "children", "ref"],
|
|
5
5
|
_excluded2 = ["form", "footer"],
|
|
6
6
|
_excluded3 = ["form"];
|
|
7
7
|
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; }
|
|
@@ -35,7 +35,7 @@ var FormModal = /*#__PURE__*/memo(function (_ref) {
|
|
|
35
35
|
centered = _ref.centered,
|
|
36
36
|
open = _ref.open,
|
|
37
37
|
afterClose = _ref.afterClose,
|
|
38
|
-
|
|
38
|
+
destroyOnHidden = _ref.destroyOnHidden,
|
|
39
39
|
closeIcon = _ref.closeIcon,
|
|
40
40
|
paddings = _ref.paddings,
|
|
41
41
|
height = _ref.height,
|
|
@@ -79,7 +79,7 @@ var FormModal = /*#__PURE__*/memo(function (_ref) {
|
|
|
79
79
|
closable: closable,
|
|
80
80
|
closeIcon: closeIcon,
|
|
81
81
|
confirmLoading: submitLoading,
|
|
82
|
-
|
|
82
|
+
destroyOnHidden: destroyOnHidden,
|
|
83
83
|
enableResponsive: enableResponsive,
|
|
84
84
|
focusTriggerAfterClose: focusTriggerAfterClose,
|
|
85
85
|
footer: null,
|
|
@@ -103,7 +103,7 @@ var FormModal = /*#__PURE__*/memo(function (_ref) {
|
|
|
103
103
|
zIndex: zIndex,
|
|
104
104
|
children: /*#__PURE__*/_jsx(Form, _objectSpread(_objectSpread({
|
|
105
105
|
className: cx(s.form, formClassName),
|
|
106
|
-
clearOnDestroy:
|
|
106
|
+
clearOnDestroy: destroyOnHidden,
|
|
107
107
|
footer: /*#__PURE__*/_jsx(Flexbox, {
|
|
108
108
|
align: 'center',
|
|
109
109
|
className: cx(s.footer, footerClassName),
|
package/es/FormModal/type.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Ref } from 'react';
|
|
|
2
2
|
import type { ButtonProps } from "../Button";
|
|
3
3
|
import type { FormInstance, FormProps } from "../Form";
|
|
4
4
|
import type { ModalProps } from "../Modal";
|
|
5
|
-
type PickModalProps = Pick<ModalProps, 'style' | 'className' | 'allowFullscreen' | 'title' | 'width' | 'onCancel' | 'open' | 'centered' | '
|
|
5
|
+
type PickModalProps = Pick<ModalProps, 'style' | 'className' | 'allowFullscreen' | 'title' | 'width' | 'onCancel' | 'open' | 'centered' | 'destroyOnHidden' | 'paddings' | 'height' | 'enableResponsive' | 'afterClose' | 'afterOpenChange' | 'zIndex' | 'mask' | 'getContainer' | 'keyboard' | 'forceRender' | 'focusTriggerAfterClose' | 'closable' | 'loading' | 'closeIcon'>;
|
|
6
6
|
type PickFormProps = Omit<FormProps, 'className' | 'style' | 'title'>;
|
|
7
7
|
export interface FormModalProps extends PickModalProps, PickFormProps {
|
|
8
8
|
classNames?: {
|
package/es/Markdown/Markdown.js
CHANGED
|
@@ -17,6 +17,8 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
17
17
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
18
18
|
import { cva } from 'class-variance-authority';
|
|
19
19
|
import { memo, useEffect, useMemo, useState } from 'react';
|
|
20
|
+
import { PreviewGroup } from "../Image";
|
|
21
|
+
import { MarkdownProvider } from "./components/MarkdownProvider";
|
|
20
22
|
import SyntaxMarkdown from "./SyntaxMarkdown";
|
|
21
23
|
import Typography from "./Typography";
|
|
22
24
|
import { useStyles } from "./style";
|
|
@@ -108,42 +110,49 @@ var Markdown = /*#__PURE__*/memo(function (_ref) {
|
|
|
108
110
|
/* eslint-enable sort-keys-fix/sort-keys-fix */
|
|
109
111
|
});
|
|
110
112
|
}, [styles]);
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
animated: delayedAnimated,
|
|
114
|
-
enableLatex: enableLatex,
|
|
115
|
-
variant: variant
|
|
116
|
-
}), className),
|
|
117
|
-
"data-code-type": "markdown",
|
|
118
|
-
fontSize: fontSize,
|
|
119
|
-
headerMultiple: headerMultiple,
|
|
120
|
-
lineHeight: lineHeight,
|
|
121
|
-
marginMultiple: marginMultiple,
|
|
122
|
-
onDoubleClick: onDoubleClick,
|
|
123
|
-
ref: ref,
|
|
124
|
-
style: style
|
|
125
|
-
}, rest), {}, {
|
|
126
|
-
children: /*#__PURE__*/_jsx(SyntaxMarkdown, {
|
|
127
|
-
allowHtml: allowHtml,
|
|
128
|
-
animated: delayedAnimated,
|
|
129
|
-
citations: citations,
|
|
130
|
-
componentProps: componentProps,
|
|
131
|
-
components: components,
|
|
132
|
-
customRender: customRender,
|
|
133
|
-
enableCustomFootnotes: enableCustomFootnotes,
|
|
134
|
-
enableImageGallery: enableImageGallery,
|
|
135
|
-
enableLatex: enableLatex,
|
|
136
|
-
enableMermaid: enableMermaid,
|
|
137
|
-
fullFeaturedCodeBlock: fullFeaturedCodeBlock,
|
|
138
|
-
reactMarkdownProps: reactMarkdownProps,
|
|
139
|
-
rehypePlugins: rehypePlugins,
|
|
140
|
-
remarkPlugins: remarkPlugins,
|
|
141
|
-
remarkPluginsAhead: remarkPluginsAhead,
|
|
142
|
-
showFootnotes: showFootnotes,
|
|
143
|
-
variant: variant,
|
|
144
|
-
children: children
|
|
145
|
-
})
|
|
113
|
+
var defaultDOM = /*#__PURE__*/_jsx(SyntaxMarkdown, _objectSpread(_objectSpread({}, reactMarkdownProps), {}, {
|
|
114
|
+
children: children
|
|
146
115
|
}));
|
|
116
|
+
return /*#__PURE__*/_jsx(PreviewGroup, {
|
|
117
|
+
enable: enableImageGallery,
|
|
118
|
+
children: /*#__PURE__*/_jsx(Typography, _objectSpread(_objectSpread({
|
|
119
|
+
className: cx(variants({
|
|
120
|
+
animated: delayedAnimated,
|
|
121
|
+
enableLatex: enableLatex,
|
|
122
|
+
variant: variant
|
|
123
|
+
}), className),
|
|
124
|
+
"data-code-type": "markdown",
|
|
125
|
+
fontSize: fontSize,
|
|
126
|
+
headerMultiple: headerMultiple,
|
|
127
|
+
lineHeight: lineHeight,
|
|
128
|
+
marginMultiple: marginMultiple,
|
|
129
|
+
onDoubleClick: onDoubleClick,
|
|
130
|
+
ref: ref,
|
|
131
|
+
style: style
|
|
132
|
+
}, rest), {}, {
|
|
133
|
+
children: /*#__PURE__*/_jsx(MarkdownProvider, {
|
|
134
|
+
config: {
|
|
135
|
+
allowHtml: allowHtml,
|
|
136
|
+
animated: delayedAnimated,
|
|
137
|
+
citations: citations,
|
|
138
|
+
componentProps: componentProps,
|
|
139
|
+
components: components,
|
|
140
|
+
enableCustomFootnotes: enableCustomFootnotes,
|
|
141
|
+
enableLatex: enableLatex,
|
|
142
|
+
enableMermaid: enableMermaid,
|
|
143
|
+
fullFeaturedCodeBlock: fullFeaturedCodeBlock,
|
|
144
|
+
rehypePlugins: rehypePlugins,
|
|
145
|
+
remarkPlugins: remarkPlugins,
|
|
146
|
+
remarkPluginsAhead: remarkPluginsAhead,
|
|
147
|
+
showFootnotes: showFootnotes,
|
|
148
|
+
variant: variant
|
|
149
|
+
},
|
|
150
|
+
children: customRender ? customRender(defaultDOM, {
|
|
151
|
+
text: children || ''
|
|
152
|
+
}) : defaultDOM
|
|
153
|
+
})
|
|
154
|
+
}))
|
|
155
|
+
});
|
|
147
156
|
});
|
|
148
157
|
Markdown.displayName = 'Markdown';
|
|
149
158
|
export default Markdown;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
3
|
-
declare const SyntaxMarkdown: import("react").NamedExoticComponent<SyntaxMarkdownProps>;
|
|
2
|
+
declare const SyntaxMarkdown: import("react").NamedExoticComponent<import("react-markdown/lib").Options>;
|
|
4
3
|
export default SyntaxMarkdown;
|
|
@@ -1,111 +1,40 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
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); }
|
|
4
|
+
var _excluded = ["children"],
|
|
5
|
+
_excluded2 = ["children"];
|
|
4
6
|
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; }
|
|
5
7
|
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; }
|
|
6
8
|
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; }
|
|
7
9
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
8
10
|
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); }
|
|
9
|
-
|
|
11
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
12
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
13
|
+
import { memo } from 'react';
|
|
10
14
|
import Markdown from 'react-markdown';
|
|
11
|
-
import {
|
|
12
|
-
import { useMarkdown, useMarkdownContent } from "../../hooks/useMarkdown";
|
|
15
|
+
import { useMarkdownComponents, useMarkdownContent, useMarkdownRehypePlugins, useMarkdownRemarkPlugins } from "../../hooks/useMarkdown";
|
|
13
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
// Create a pure component that only renders ReactMarkdown
|
|
15
|
-
// This helps prevent unnecessary rerenders of ReactMarkdown
|
|
16
17
|
var MarkdownRenderer = /*#__PURE__*/memo(function (_ref) {
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
components: memoComponents,
|
|
18
|
+
var children = _ref.children,
|
|
19
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
20
|
+
var components = useMarkdownComponents();
|
|
21
|
+
var rehypePluginsList = useMarkdownRehypePlugins();
|
|
22
|
+
var remarkPluginsList = useMarkdownRemarkPlugins();
|
|
23
|
+
return /*#__PURE__*/_jsx(Markdown, _objectSpread(_objectSpread({}, rest), {}, {
|
|
24
|
+
components: components,
|
|
25
25
|
rehypePlugins: rehypePluginsList,
|
|
26
26
|
remarkPlugins: remarkPluginsList,
|
|
27
|
-
children:
|
|
27
|
+
children: children
|
|
28
28
|
}));
|
|
29
|
-
if (!enableImageGallery) return content;
|
|
30
|
-
return /*#__PURE__*/_jsx(PreviewGroup, {
|
|
31
|
-
enable: enableImageGallery,
|
|
32
|
-
children: content
|
|
33
|
-
});
|
|
34
29
|
});
|
|
35
30
|
MarkdownRenderer.displayName = 'MarkdownRenderer';
|
|
36
31
|
var SyntaxMarkdown = /*#__PURE__*/memo(function (_ref2) {
|
|
37
32
|
var children = _ref2.children,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
enableMermaid = _ref2$enableMermaid === void 0 ? true : _ref2$enableMermaid,
|
|
44
|
-
enableImageGallery = _ref2.enableImageGallery,
|
|
45
|
-
enableCustomFootnotes = _ref2.enableCustomFootnotes,
|
|
46
|
-
componentProps = _ref2.componentProps,
|
|
47
|
-
allowHtml = _ref2.allowHtml,
|
|
48
|
-
showFootnotes = _ref2.showFootnotes,
|
|
49
|
-
_ref2$variant = _ref2.variant,
|
|
50
|
-
variant = _ref2$variant === void 0 ? 'default' : _ref2$variant,
|
|
51
|
-
reactMarkdownProps = _ref2.reactMarkdownProps,
|
|
52
|
-
rehypePlugins = _ref2.rehypePlugins,
|
|
53
|
-
remarkPlugins = _ref2.remarkPlugins,
|
|
54
|
-
remarkPluginsAhead = _ref2.remarkPluginsAhead,
|
|
55
|
-
_ref2$components = _ref2.components,
|
|
56
|
-
components = _ref2$components === void 0 ? {} : _ref2$components,
|
|
57
|
-
customRender = _ref2.customRender,
|
|
58
|
-
citations = _ref2.citations;
|
|
59
|
-
var escapedContent = useMarkdownContent({
|
|
60
|
-
animated: animated,
|
|
61
|
-
children: children,
|
|
62
|
-
citations: citations,
|
|
63
|
-
enableCustomFootnotes: enableCustomFootnotes,
|
|
64
|
-
enableLatex: enableLatex
|
|
65
|
-
});
|
|
66
|
-
var _useMarkdown = useMarkdown({
|
|
67
|
-
allowHtml: allowHtml,
|
|
68
|
-
animated: animated,
|
|
69
|
-
citations: citations,
|
|
70
|
-
componentProps: componentProps,
|
|
71
|
-
components: components,
|
|
72
|
-
enableCustomFootnotes: enableCustomFootnotes,
|
|
73
|
-
enableImageGallery: enableImageGallery,
|
|
74
|
-
enableLatex: enableLatex,
|
|
75
|
-
enableMermaid: enableMermaid,
|
|
76
|
-
fullFeaturedCodeBlock: fullFeaturedCodeBlock,
|
|
77
|
-
rehypePlugins: rehypePlugins,
|
|
78
|
-
remarkPlugins: remarkPlugins,
|
|
79
|
-
remarkPluginsAhead: remarkPluginsAhead,
|
|
80
|
-
showFootnotes: showFootnotes,
|
|
81
|
-
variant: variant
|
|
82
|
-
}),
|
|
83
|
-
memoComponents = _useMarkdown.memoComponents,
|
|
84
|
-
rehypePluginsList = _useMarkdown.rehypePluginsList,
|
|
85
|
-
remarkPluginsList = _useMarkdown.remarkPluginsList;
|
|
86
|
-
|
|
87
|
-
// Memoize the renderer configuration to prevent unnecessary re-renders
|
|
88
|
-
var rendererProps = useMemo(function () {
|
|
89
|
-
return {
|
|
90
|
-
enableImageGallery: enableImageGallery,
|
|
91
|
-
memoComponents: memoComponents,
|
|
92
|
-
reactMarkdownProps: reactMarkdownProps,
|
|
93
|
-
rehypePluginsList: rehypePluginsList,
|
|
94
|
-
remarkPluginsList: remarkPluginsList
|
|
95
|
-
};
|
|
96
|
-
}, [memoComponents, rehypePluginsList, remarkPluginsList, enableImageGallery, reactMarkdownProps]);
|
|
97
|
-
|
|
98
|
-
// Render default content using memoized MarkdownRenderer
|
|
99
|
-
var defaultDOM = useMemo(function () {
|
|
100
|
-
return /*#__PURE__*/_jsx(MarkdownRenderer, _objectSpread({
|
|
101
|
-
escapedContent: escapedContent
|
|
102
|
-
}, rendererProps));
|
|
103
|
-
}, [rendererProps, escapedContent]);
|
|
104
|
-
|
|
105
|
-
// Apply custom rendering if needed
|
|
106
|
-
return customRender ? customRender(defaultDOM, {
|
|
107
|
-
text: escapedContent || ''
|
|
108
|
-
}) : defaultDOM;
|
|
33
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
34
|
+
var escapedContent = useMarkdownContent(children || '');
|
|
35
|
+
return /*#__PURE__*/_jsx(MarkdownRenderer, _objectSpread(_objectSpread({}, rest), {}, {
|
|
36
|
+
children: escapedContent
|
|
37
|
+
}));
|
|
109
38
|
});
|
|
110
39
|
SyntaxMarkdown.displayName = 'SyntaxMarkdown';
|
|
111
40
|
export default SyntaxMarkdown;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { SyntaxMarkdownProps } from '../type';
|
|
3
|
+
export type MarkdownContentConfig = Omit<SyntaxMarkdownProps, 'children' | 'reactMarkdownProps'>;
|
|
4
|
+
export declare const MarkdownContext: import("react").Context<MarkdownContentConfig>;
|
|
5
|
+
export declare const MarkdownProvider: import("react").NamedExoticComponent<{
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
config?: MarkdownContentConfig | undefined;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const useMarkdownContext: () => MarkdownContentConfig;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { createContext, memo, use } from 'react';
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
export var MarkdownContext = /*#__PURE__*/createContext({});
|
|
6
|
+
export var MarkdownProvider = /*#__PURE__*/memo(function (_ref) {
|
|
7
|
+
var children = _ref.children,
|
|
8
|
+
_ref$config = _ref.config,
|
|
9
|
+
config = _ref$config === void 0 ? {} : _ref$config;
|
|
10
|
+
return /*#__PURE__*/_jsx(MarkdownContext, {
|
|
11
|
+
value: config,
|
|
12
|
+
children: children
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
export var useMarkdownContext = function useMarkdownContext() {
|
|
16
|
+
return use(MarkdownContext);
|
|
17
|
+
};
|
package/es/Markdown/type.d.ts
CHANGED
|
@@ -29,16 +29,13 @@ export interface SyntaxMarkdownProps {
|
|
|
29
29
|
video?: Partial<VideoProps>;
|
|
30
30
|
};
|
|
31
31
|
components?: Components & Record<string, FC>;
|
|
32
|
-
customRender?: (dom: ReactNode, context: {
|
|
33
|
-
text: string;
|
|
34
|
-
}) => ReactNode;
|
|
35
32
|
enableCustomFootnotes?: boolean;
|
|
36
|
-
enableImageGallery?: boolean;
|
|
37
33
|
enableLatex?: boolean;
|
|
38
34
|
enableMermaid?: boolean;
|
|
39
35
|
fullFeaturedCodeBlock?: boolean;
|
|
40
36
|
reactMarkdownProps?: Omit<Readonly<ReactMarkdownOptions>, 'components' | 'rehypePlugins' | 'remarkPlugins'>;
|
|
41
37
|
rehypePlugins?: Pluggable[];
|
|
38
|
+
rehypePluginsAhead?: Pluggable[];
|
|
42
39
|
remarkPlugins?: Pluggable[];
|
|
43
40
|
remarkPluginsAhead?: Pluggable[];
|
|
44
41
|
showFootnotes?: boolean;
|
|
@@ -46,6 +43,10 @@ export interface SyntaxMarkdownProps {
|
|
|
46
43
|
}
|
|
47
44
|
export interface MarkdownProps extends SyntaxMarkdownProps, Omit<TypographyProps, 'children'> {
|
|
48
45
|
className?: string;
|
|
46
|
+
customRender?: (dom: ReactNode, context: {
|
|
47
|
+
text: string;
|
|
48
|
+
}) => ReactNode;
|
|
49
|
+
enableImageGallery?: boolean;
|
|
49
50
|
onDoubleClick?: () => void;
|
|
50
51
|
ref?: Ref<HTMLDivElement>;
|
|
51
52
|
style?: CSSProperties;
|
package/es/Modal/Modal.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
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); }
|
|
4
|
-
var _excluded = ["panelRef", "allowFullscreen", "children", "title", "className", "classNames", "width", "onCancel", "open", "
|
|
4
|
+
var _excluded = ["panelRef", "allowFullscreen", "children", "title", "className", "classNames", "width", "onCancel", "open", "destroyOnHidden", "paddings", "height", "enableResponsive", "footer", "styles", "okText", "onOk", "cancelText", "okButtonProps", "cancelButtonProps", "confirmLoading"],
|
|
5
5
|
_excluded2 = ["body"];
|
|
6
6
|
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; }
|
|
7
7
|
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; }
|
|
@@ -39,7 +39,7 @@ var Modal = /*#__PURE__*/memo(function (_ref) {
|
|
|
39
39
|
width = _ref$width === void 0 ? 700 : _ref$width,
|
|
40
40
|
onCancel = _ref.onCancel,
|
|
41
41
|
open = _ref.open,
|
|
42
|
-
|
|
42
|
+
destroyOnHidden = _ref.destroyOnHidden,
|
|
43
43
|
paddings = _ref.paddings,
|
|
44
44
|
_ref$height = _ref.height,
|
|
45
45
|
height = _ref$height === void 0 ? '75dvh' : _ref$height,
|
|
@@ -82,7 +82,7 @@ var Modal = /*#__PURE__*/memo(function (_ref) {
|
|
|
82
82
|
closeIcon: /*#__PURE__*/_jsx(ActionIcon, {
|
|
83
83
|
icon: X
|
|
84
84
|
}),
|
|
85
|
-
|
|
85
|
+
destroyOnHidden: destroyOnHidden,
|
|
86
86
|
extra: allowFullscreen && /*#__PURE__*/_jsx(ActionIcon, {
|
|
87
87
|
icon: fullscreen ? Minimize2 : Maximize2,
|
|
88
88
|
onClick: function onClick() {
|
|
@@ -145,7 +145,7 @@ var Modal = /*#__PURE__*/memo(function (_ref) {
|
|
|
145
145
|
size: 20
|
|
146
146
|
}),
|
|
147
147
|
confirmLoading: confirmLoading,
|
|
148
|
-
|
|
148
|
+
destroyOnHidden: destroyOnHidden,
|
|
149
149
|
footer: hideFooter ? null : footer,
|
|
150
150
|
maskClosable: true,
|
|
151
151
|
okButtonProps: okButtonProps,
|
|
@@ -79,7 +79,7 @@ var MessageModal = /*#__PURE__*/memo(function (_ref) {
|
|
|
79
79
|
return /*#__PURE__*/_jsx(Modal, {
|
|
80
80
|
allowFullscreen: true,
|
|
81
81
|
cancelText: (text === null || text === void 0 ? void 0 : text.cancel) || 'Cancel',
|
|
82
|
-
|
|
82
|
+
destroyOnHidden: true,
|
|
83
83
|
footer: modalFooter,
|
|
84
84
|
height: height,
|
|
85
85
|
okText: (text === null || text === void 0 ? void 0 : text.edit) || 'Edit',
|
|
@@ -1,14 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Processes Markdown content and prepares rendering components and configurations
|
|
6
|
-
* Optimized version with better memoization and performance
|
|
7
|
-
*/
|
|
8
|
-
export declare const useMarkdown: ({ fullFeaturedCodeBlock, animated, enableLatex, enableMermaid, enableImageGallery, enableCustomFootnotes, componentProps, allowHtml, showFootnotes, variant, rehypePlugins, remarkPlugins, remarkPluginsAhead, components, citations, }: Pick<MarkdownProps, 'fullFeaturedCodeBlock' | 'animated' | 'enableLatex' | 'enableMermaid' | 'enableImageGallery' | 'enableCustomFootnotes' | 'componentProps' | 'allowHtml' | 'showFootnotes' | 'variant' | 'rehypePlugins' | 'remarkPlugins' | 'remarkPluginsAhead' | 'components' | 'citations'>) => {
|
|
9
|
-
escapedContent?: string | undefined;
|
|
10
|
-
memoComponents: Components;
|
|
11
|
-
rehypePluginsList: Pluggable[];
|
|
12
|
-
remarkPluginsList: Pluggable[];
|
|
13
|
-
};
|
|
14
|
-
export declare const useMarkdownContent: ({ children, animated, enableLatex, enableCustomFootnotes, citations, }: Pick<MarkdownProps, 'children' | 'animated' | 'enableLatex' | 'enableCustomFootnotes' | 'citations'>) => string | undefined;
|
|
1
|
+
export { useMarkdownComponents } from './useMarkdownComponents';
|
|
2
|
+
export { useMarkdownContent } from './useMarkdownContent';
|
|
3
|
+
export { useMarkdownRehypePlugins } from './useMarkdownRehypePlugins';
|
|
4
|
+
export { useMarkdownRemarkPlugins } from './useMarkdownRemarkPlugins';
|
|
@@ -1,226 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
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."); }
|
|
6
|
-
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); }
|
|
7
|
-
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; }
|
|
8
|
-
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; } }
|
|
9
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
10
|
-
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; }
|
|
11
|
-
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; }
|
|
12
|
-
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; }
|
|
13
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
14
|
-
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); }
|
|
15
|
-
import { useMemo, useRef, useState } from 'react';
|
|
16
|
-
import { CodeBlock } from "../../Markdown/components/CodeBlock";
|
|
17
|
-
import Image from "../../mdx/mdxComponents/Image";
|
|
18
|
-
import Link from "../../mdx/mdxComponents/Link";
|
|
19
|
-
import Section from "../../mdx/mdxComponents/Section";
|
|
20
|
-
import Video from "../../mdx/mdxComponents/Video";
|
|
21
|
-
import { isLastFormulaRenderable } from "./latex";
|
|
22
|
-
import { addToCache, contentCache, createPlugins, preprocessContent } from "./utils";
|
|
23
|
-
|
|
24
|
-
// Define component factory types
|
|
25
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
|
-
/**
|
|
27
|
-
* Creates reusable component factories that can be memoized once
|
|
28
|
-
* and reused across multiple renders without recreation
|
|
29
|
-
*/
|
|
30
|
-
var createComponentFactories = function createComponentFactories(params) {
|
|
31
|
-
var citations = params.citations,
|
|
32
|
-
componentProps = params.componentProps,
|
|
33
|
-
animated = params.animated,
|
|
34
|
-
enableMermaid = params.enableMermaid,
|
|
35
|
-
fullFeaturedCodeBlock = params.fullFeaturedCodeBlock,
|
|
36
|
-
showFootnotes = params.showFootnotes;
|
|
37
|
-
return {
|
|
38
|
-
a: function a(props) {
|
|
39
|
-
return /*#__PURE__*/_jsx(Link, _objectSpread(_objectSpread({
|
|
40
|
-
citations: citations
|
|
41
|
-
}, props), componentProps === null || componentProps === void 0 ? void 0 : componentProps.a));
|
|
42
|
-
},
|
|
43
|
-
img: function img(props) {
|
|
44
|
-
return /*#__PURE__*/_jsx(Image, _objectSpread(_objectSpread({}, props), componentProps === null || componentProps === void 0 ? void 0 : componentProps.img));
|
|
45
|
-
},
|
|
46
|
-
pre: function pre(props) {
|
|
47
|
-
return /*#__PURE__*/_jsx(CodeBlock, _objectSpread(_objectSpread({
|
|
48
|
-
animated: animated,
|
|
49
|
-
enableMermaid: enableMermaid,
|
|
50
|
-
fullFeatured: fullFeaturedCodeBlock,
|
|
51
|
-
highlight: componentProps === null || componentProps === void 0 ? void 0 : componentProps.highlight,
|
|
52
|
-
mermaid: componentProps === null || componentProps === void 0 ? void 0 : componentProps.mermaid
|
|
53
|
-
}, componentProps === null || componentProps === void 0 ? void 0 : componentProps.pre), props));
|
|
54
|
-
},
|
|
55
|
-
section: function section(props) {
|
|
56
|
-
return /*#__PURE__*/_jsx(Section, _objectSpread({
|
|
57
|
-
showFootnotes: showFootnotes
|
|
58
|
-
}, props));
|
|
59
|
-
},
|
|
60
|
-
video: function video(props) {
|
|
61
|
-
return /*#__PURE__*/_jsx(Video, _objectSpread(_objectSpread({}, props), componentProps === null || componentProps === void 0 ? void 0 : componentProps.video));
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Processes Markdown content and prepares rendering components and configurations
|
|
68
|
-
* Optimized version with better memoization and performance
|
|
69
|
-
*/
|
|
70
|
-
export var useMarkdown = function useMarkdown(_ref) {
|
|
71
|
-
var _componentProps$highl2, _componentProps$merma2;
|
|
72
|
-
var fullFeaturedCodeBlock = _ref.fullFeaturedCodeBlock,
|
|
73
|
-
animated = _ref.animated,
|
|
74
|
-
_ref$enableLatex = _ref.enableLatex,
|
|
75
|
-
enableLatex = _ref$enableLatex === void 0 ? true : _ref$enableLatex,
|
|
76
|
-
_ref$enableMermaid = _ref.enableMermaid,
|
|
77
|
-
enableMermaid = _ref$enableMermaid === void 0 ? true : _ref$enableMermaid,
|
|
78
|
-
enableImageGallery = _ref.enableImageGallery,
|
|
79
|
-
enableCustomFootnotes = _ref.enableCustomFootnotes,
|
|
80
|
-
componentProps = _ref.componentProps,
|
|
81
|
-
allowHtml = _ref.allowHtml,
|
|
82
|
-
showFootnotes = _ref.showFootnotes,
|
|
83
|
-
_ref$variant = _ref.variant,
|
|
84
|
-
variant = _ref$variant === void 0 ? 'default' : _ref$variant,
|
|
85
|
-
rehypePlugins = _ref.rehypePlugins,
|
|
86
|
-
remarkPlugins = _ref.remarkPlugins,
|
|
87
|
-
remarkPluginsAhead = _ref.remarkPluginsAhead,
|
|
88
|
-
_ref$components = _ref.components,
|
|
89
|
-
components = _ref$components === void 0 ? {} : _ref$components,
|
|
90
|
-
citations = _ref.citations;
|
|
91
|
-
var isChatMode = variant === 'chat';
|
|
92
|
-
|
|
93
|
-
// Create a memoized options object for plugin creation
|
|
94
|
-
var pluginOptions = useMemo(function () {
|
|
95
|
-
return {
|
|
96
|
-
allowHtml: allowHtml,
|
|
97
|
-
animated: animated,
|
|
98
|
-
enableCustomFootnotes: enableCustomFootnotes,
|
|
99
|
-
enableLatex: enableLatex,
|
|
100
|
-
isChatMode: isChatMode,
|
|
101
|
-
rehypePlugins: rehypePlugins,
|
|
102
|
-
remarkPlugins: remarkPlugins,
|
|
103
|
-
remarkPluginsAhead: remarkPluginsAhead
|
|
104
|
-
};
|
|
105
|
-
}, [allowHtml, animated, enableCustomFootnotes, enableLatex, isChatMode, rehypePlugins, remarkPlugins, remarkPluginsAhead]);
|
|
106
|
-
|
|
107
|
-
// Create plugins with better memoization
|
|
108
|
-
var _useMemo = useMemo(function () {
|
|
109
|
-
return createPlugins(pluginOptions);
|
|
110
|
-
}, [pluginOptions]),
|
|
111
|
-
rehypePluginsList = _useMemo.rehypePluginsList,
|
|
112
|
-
remarkPluginsList = _useMemo.remarkPluginsList;
|
|
113
|
-
|
|
114
|
-
// Stable references for theme objects to prevent unnecessary re-renders
|
|
115
|
-
var highlightTheme = useMemo(function () {
|
|
116
|
-
var _componentProps$highl;
|
|
117
|
-
return componentProps === null || componentProps === void 0 || (_componentProps$highl = componentProps.highlight) === null || _componentProps$highl === void 0 ? void 0 : _componentProps$highl.theme;
|
|
118
|
-
}, [JSON.stringify(componentProps === null || componentProps === void 0 || (_componentProps$highl2 = componentProps.highlight) === null || _componentProps$highl2 === void 0 ? void 0 : _componentProps$highl2.theme)]);
|
|
119
|
-
var mermaidTheme = useMemo(function () {
|
|
120
|
-
var _componentProps$merma;
|
|
121
|
-
return componentProps === null || componentProps === void 0 || (_componentProps$merma = componentProps.mermaid) === null || _componentProps$merma === void 0 ? void 0 : _componentProps$merma.theme;
|
|
122
|
-
}, [JSON.stringify(componentProps === null || componentProps === void 0 || (_componentProps$merma2 = componentProps.mermaid) === null || _componentProps$merma2 === void 0 ? void 0 : _componentProps$merma2.theme)]);
|
|
123
|
-
|
|
124
|
-
// Create stable component props reference
|
|
125
|
-
var stableComponentProps = useMemo(function () {
|
|
126
|
-
if (!componentProps) return;
|
|
127
|
-
return _objectSpread(_objectSpread({}, componentProps), {}, {
|
|
128
|
-
highlight: componentProps.highlight ? _objectSpread(_objectSpread({}, componentProps.highlight), {}, {
|
|
129
|
-
theme: highlightTheme
|
|
130
|
-
}) : undefined,
|
|
131
|
-
mermaid: componentProps.mermaid ? _objectSpread(_objectSpread({}, componentProps.mermaid), {}, {
|
|
132
|
-
theme: mermaidTheme
|
|
133
|
-
}) : undefined
|
|
134
|
-
});
|
|
135
|
-
}, [componentProps === null || componentProps === void 0 ? void 0 : componentProps.a, componentProps === null || componentProps === void 0 ? void 0 : componentProps.img, componentProps === null || componentProps === void 0 ? void 0 : componentProps.pre, componentProps === null || componentProps === void 0 ? void 0 : componentProps.video, highlightTheme, mermaidTheme]);
|
|
136
|
-
|
|
137
|
-
// Memoize the factory parameters to prevent recreating component factories
|
|
138
|
-
var factoryParams = useMemo(function () {
|
|
139
|
-
return {
|
|
140
|
-
animated: animated || false,
|
|
141
|
-
// Ensure animated is always a boolean
|
|
142
|
-
citations: citations,
|
|
143
|
-
componentProps: stableComponentProps,
|
|
144
|
-
enableMermaid: enableMermaid,
|
|
145
|
-
fullFeaturedCodeBlock: fullFeaturedCodeBlock,
|
|
146
|
-
showFootnotes: showFootnotes
|
|
147
|
-
};
|
|
148
|
-
}, [animated, citations, stableComponentProps, enableMermaid, fullFeaturedCodeBlock, showFootnotes]);
|
|
149
|
-
|
|
150
|
-
// Create component factories once and reuse them
|
|
151
|
-
var componentFactories = useMemo(function () {
|
|
152
|
-
return createComponentFactories(factoryParams);
|
|
153
|
-
}, [factoryParams]);
|
|
154
|
-
|
|
155
|
-
// Create the final components object with proper memoization
|
|
156
|
-
var memoComponents = useMemo(function () {
|
|
157
|
-
return _objectSpread({
|
|
158
|
-
a: componentFactories.a,
|
|
159
|
-
img: enableImageGallery ? componentFactories.img : undefined,
|
|
160
|
-
pre: componentFactories.pre,
|
|
161
|
-
section: componentFactories.section,
|
|
162
|
-
video: componentFactories.video
|
|
163
|
-
}, components);
|
|
164
|
-
}, [componentFactories, enableImageGallery, components]);
|
|
165
|
-
|
|
166
|
-
// Return memoized result to prevent unnecessary recalculations
|
|
167
|
-
return useMemo(function () {
|
|
168
|
-
return {
|
|
169
|
-
memoComponents: memoComponents,
|
|
170
|
-
rehypePluginsList: rehypePluginsList,
|
|
171
|
-
remarkPluginsList: remarkPluginsList
|
|
172
|
-
};
|
|
173
|
-
}, [memoComponents, rehypePluginsList, remarkPluginsList]);
|
|
174
|
-
};
|
|
175
|
-
export var useMarkdownContent = function useMarkdownContent(_ref2) {
|
|
176
|
-
var children = _ref2.children,
|
|
177
|
-
animated = _ref2.animated,
|
|
178
|
-
_ref2$enableLatex = _ref2.enableLatex,
|
|
179
|
-
enableLatex = _ref2$enableLatex === void 0 ? true : _ref2$enableLatex,
|
|
180
|
-
enableCustomFootnotes = _ref2.enableCustomFootnotes,
|
|
181
|
-
citations = _ref2.citations;
|
|
182
|
-
var _useState = useState(''),
|
|
183
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
184
|
-
validContent = _useState2[0],
|
|
185
|
-
setValidContent = _useState2[1];
|
|
186
|
-
var prevProcessedContent = useRef('');
|
|
187
|
-
var citationsLength = (citations === null || citations === void 0 ? void 0 : citations.length) || 0;
|
|
188
|
-
|
|
189
|
-
// Calculate cache key with fewer string concatenations and better performance
|
|
190
|
-
var cacheKey = useMemo(function () {
|
|
191
|
-
return "".concat(children, "|").concat(enableLatex ? 1 : 0, "|").concat(enableCustomFootnotes ? 1 : 0, "|").concat(citationsLength);
|
|
192
|
-
}, [children, enableLatex, enableCustomFootnotes, citationsLength]);
|
|
193
|
-
|
|
194
|
-
// Process content and use cache to avoid repeated calculations
|
|
195
|
-
return useMemo(function () {
|
|
196
|
-
// Try to get from cache first for best performance
|
|
197
|
-
if (contentCache.has(cacheKey)) {
|
|
198
|
-
return contentCache.get(cacheKey);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// Process new content only if needed
|
|
202
|
-
var processedContent = preprocessContent(children, {
|
|
203
|
-
citationsLength: citationsLength,
|
|
204
|
-
enableCustomFootnotes: enableCustomFootnotes,
|
|
205
|
-
enableLatex: enableLatex
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
// Special handling for LaTeX content when animated
|
|
209
|
-
if (animated && enableLatex) {
|
|
210
|
-
var isRenderable = isLastFormulaRenderable(processedContent);
|
|
211
|
-
if (!isRenderable && validContent) {
|
|
212
|
-
processedContent = validContent;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// Only update state if content changed (prevents unnecessary re-renders)
|
|
217
|
-
if (processedContent !== prevProcessedContent.current) {
|
|
218
|
-
setValidContent(processedContent);
|
|
219
|
-
prevProcessedContent.current = processedContent;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// Cache the processed result
|
|
223
|
-
addToCache(cacheKey, processedContent);
|
|
224
|
-
return processedContent;
|
|
225
|
-
}, [cacheKey, children, enableLatex, enableCustomFootnotes, citationsLength, animated, validContent]);
|
|
226
|
-
};
|
|
1
|
+
export { useMarkdownComponents } from "./useMarkdownComponents";
|
|
2
|
+
export { useMarkdownContent } from "./useMarkdownContent";
|
|
3
|
+
export { useMarkdownRehypePlugins } from "./useMarkdownRehypePlugins";
|
|
4
|
+
export { useMarkdownRemarkPlugins } from "./useMarkdownRemarkPlugins";
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
8
|
+
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); }
|
|
9
|
+
import { useMemo } from 'react';
|
|
10
|
+
import { CodeBlock } from "../../Markdown/components/CodeBlock";
|
|
11
|
+
import { useMarkdownContext } from "../../Markdown/components/MarkdownProvider";
|
|
12
|
+
import Image from "../../mdx/mdxComponents/Image";
|
|
13
|
+
import Link from "../../mdx/mdxComponents/Link";
|
|
14
|
+
import Section from "../../mdx/mdxComponents/Section";
|
|
15
|
+
import Video from "../../mdx/mdxComponents/Video";
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
export var useMarkdownComponents = function useMarkdownComponents() {
|
|
18
|
+
var _componentProps$highl2, _componentProps$merma2;
|
|
19
|
+
var _useMarkdownContext = useMarkdownContext(),
|
|
20
|
+
components = _useMarkdownContext.components,
|
|
21
|
+
animated = _useMarkdownContext.animated,
|
|
22
|
+
citations = _useMarkdownContext.citations,
|
|
23
|
+
componentProps = _useMarkdownContext.componentProps,
|
|
24
|
+
showFootnotes = _useMarkdownContext.showFootnotes,
|
|
25
|
+
enableMermaid = _useMarkdownContext.enableMermaid,
|
|
26
|
+
fullFeaturedCodeBlock = _useMarkdownContext.fullFeaturedCodeBlock;
|
|
27
|
+
var memoA = useMemo(function () {
|
|
28
|
+
return function (props) {
|
|
29
|
+
return /*#__PURE__*/_jsx(Link, _objectSpread(_objectSpread({
|
|
30
|
+
citations: citations
|
|
31
|
+
}, props), componentProps === null || componentProps === void 0 ? void 0 : componentProps.a));
|
|
32
|
+
};
|
|
33
|
+
}, [citations, componentProps === null || componentProps === void 0 ? void 0 : componentProps.a]);
|
|
34
|
+
var memoImg = useMemo(function () {
|
|
35
|
+
return function (props) {
|
|
36
|
+
return /*#__PURE__*/_jsx(Image, _objectSpread(_objectSpread({}, props), componentProps === null || componentProps === void 0 ? void 0 : componentProps.img));
|
|
37
|
+
};
|
|
38
|
+
}, [componentProps === null || componentProps === void 0 ? void 0 : componentProps.img]);
|
|
39
|
+
var memoVideo = useMemo(function () {
|
|
40
|
+
return function (props) {
|
|
41
|
+
return /*#__PURE__*/_jsx(Video, _objectSpread(_objectSpread({}, props), componentProps === null || componentProps === void 0 ? void 0 : componentProps.video));
|
|
42
|
+
};
|
|
43
|
+
}, [componentProps === null || componentProps === void 0 ? void 0 : componentProps.video]);
|
|
44
|
+
var memoSection = useMemo(function () {
|
|
45
|
+
return function (props) {
|
|
46
|
+
return /*#__PURE__*/_jsx(Section, _objectSpread({
|
|
47
|
+
showFootnotes: showFootnotes
|
|
48
|
+
}, props));
|
|
49
|
+
};
|
|
50
|
+
}, [showFootnotes]);
|
|
51
|
+
|
|
52
|
+
// Stable references for theme objects to prevent unnecessary re-renders
|
|
53
|
+
var highlightTheme = useMemo(function () {
|
|
54
|
+
var _componentProps$highl;
|
|
55
|
+
return componentProps === null || componentProps === void 0 || (_componentProps$highl = componentProps.highlight) === null || _componentProps$highl === void 0 ? void 0 : _componentProps$highl.theme;
|
|
56
|
+
}, [JSON.stringify(componentProps === null || componentProps === void 0 || (_componentProps$highl2 = componentProps.highlight) === null || _componentProps$highl2 === void 0 ? void 0 : _componentProps$highl2.theme)]);
|
|
57
|
+
var mermaidTheme = useMemo(function () {
|
|
58
|
+
var _componentProps$merma;
|
|
59
|
+
return componentProps === null || componentProps === void 0 || (_componentProps$merma = componentProps.mermaid) === null || _componentProps$merma === void 0 ? void 0 : _componentProps$merma.theme;
|
|
60
|
+
}, [JSON.stringify(componentProps === null || componentProps === void 0 || (_componentProps$merma2 = componentProps.mermaid) === null || _componentProps$merma2 === void 0 ? void 0 : _componentProps$merma2.theme)]);
|
|
61
|
+
|
|
62
|
+
// Create stable component props reference
|
|
63
|
+
var stableComponentProps = useMemo(function () {
|
|
64
|
+
if (!componentProps) return;
|
|
65
|
+
return {
|
|
66
|
+
highlight: componentProps.highlight ? _objectSpread(_objectSpread({}, componentProps.highlight), {}, {
|
|
67
|
+
theme: highlightTheme
|
|
68
|
+
}) : undefined,
|
|
69
|
+
mermaid: componentProps.mermaid ? _objectSpread(_objectSpread({}, componentProps.mermaid), {}, {
|
|
70
|
+
theme: mermaidTheme
|
|
71
|
+
}) : undefined
|
|
72
|
+
};
|
|
73
|
+
}, [highlightTheme, mermaidTheme]);
|
|
74
|
+
var memoPre = useMemo(function () {
|
|
75
|
+
return function (props) {
|
|
76
|
+
return /*#__PURE__*/_jsx(CodeBlock, _objectSpread(_objectSpread(_objectSpread({
|
|
77
|
+
animated: animated,
|
|
78
|
+
enableMermaid: enableMermaid,
|
|
79
|
+
fullFeatured: fullFeaturedCodeBlock
|
|
80
|
+
}, stableComponentProps), componentProps === null || componentProps === void 0 ? void 0 : componentProps.pre), props));
|
|
81
|
+
};
|
|
82
|
+
}, [animated, enableMermaid, fullFeaturedCodeBlock, stableComponentProps, componentProps === null || componentProps === void 0 ? void 0 : componentProps.pre]);
|
|
83
|
+
var memoComponents = useMemo(function () {
|
|
84
|
+
return {
|
|
85
|
+
a: memoA,
|
|
86
|
+
img: memoImg,
|
|
87
|
+
pre: memoPre,
|
|
88
|
+
section: memoSection,
|
|
89
|
+
video: memoVideo
|
|
90
|
+
};
|
|
91
|
+
}, [memoA, memoImg, memoVideo, memoPre, memoSection]);
|
|
92
|
+
return useMemo(function () {
|
|
93
|
+
return _objectSpread(_objectSpread({}, memoComponents), components);
|
|
94
|
+
}, [memoComponents, components]);
|
|
95
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useMarkdownContent: (children: string) => string | undefined;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
+
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."); }
|
|
5
|
+
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); }
|
|
6
|
+
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; }
|
|
7
|
+
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; } }
|
|
8
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
9
|
+
import { useMemo, useRef, useState } from 'react';
|
|
10
|
+
import { useMarkdownContext } from "../../Markdown/components/MarkdownProvider";
|
|
11
|
+
import { isLastFormulaRenderable } from "./latex";
|
|
12
|
+
import { addToCache, contentCache, preprocessContent } from "./utils";
|
|
13
|
+
export var useMarkdownContent = function useMarkdownContent(children) {
|
|
14
|
+
var _useMarkdownContext = useMarkdownContext(),
|
|
15
|
+
animated = _useMarkdownContext.animated,
|
|
16
|
+
_useMarkdownContext$e = _useMarkdownContext.enableLatex,
|
|
17
|
+
enableLatex = _useMarkdownContext$e === void 0 ? true : _useMarkdownContext$e,
|
|
18
|
+
enableCustomFootnotes = _useMarkdownContext.enableCustomFootnotes,
|
|
19
|
+
citations = _useMarkdownContext.citations;
|
|
20
|
+
var _useState = useState(''),
|
|
21
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
22
|
+
validContent = _useState2[0],
|
|
23
|
+
setValidContent = _useState2[1];
|
|
24
|
+
var prevProcessedContent = useRef('');
|
|
25
|
+
var citationsLength = (citations === null || citations === void 0 ? void 0 : citations.length) || 0;
|
|
26
|
+
|
|
27
|
+
// Calculate cache key with fewer string concatenations and better performance
|
|
28
|
+
var cacheKey = useMemo(function () {
|
|
29
|
+
return "".concat(children, "|").concat(enableLatex ? 1 : 0, "|").concat(enableCustomFootnotes ? 1 : 0, "|").concat(citationsLength);
|
|
30
|
+
}, [children, enableLatex, enableCustomFootnotes, citationsLength]);
|
|
31
|
+
|
|
32
|
+
// Process content and use cache to avoid repeated calculations
|
|
33
|
+
return useMemo(function () {
|
|
34
|
+
// Try to get from cache first for best performance
|
|
35
|
+
if (contentCache.has(cacheKey)) {
|
|
36
|
+
return contentCache.get(cacheKey);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Process new content only if needed
|
|
40
|
+
var processedContent = preprocessContent(children, {
|
|
41
|
+
citationsLength: citationsLength,
|
|
42
|
+
enableCustomFootnotes: enableCustomFootnotes,
|
|
43
|
+
enableLatex: enableLatex
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Special handling for LaTeX content when animated
|
|
47
|
+
if (animated && enableLatex) {
|
|
48
|
+
var isRenderable = isLastFormulaRenderable(processedContent);
|
|
49
|
+
if (!isRenderable && validContent) {
|
|
50
|
+
processedContent = validContent;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Only update state if content changed (prevents unnecessary re-renders)
|
|
55
|
+
if (processedContent !== prevProcessedContent.current) {
|
|
56
|
+
setValidContent(processedContent);
|
|
57
|
+
prevProcessedContent.current = processedContent;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Cache the processed result
|
|
61
|
+
addToCache(cacheKey, processedContent);
|
|
62
|
+
return processedContent;
|
|
63
|
+
}, [cacheKey, children, enableLatex, enableCustomFootnotes, citationsLength, animated, validContent]);
|
|
64
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
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); }
|
|
6
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
7
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
|
+
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; }
|
|
9
|
+
import { useMemo } from 'react';
|
|
10
|
+
import rehypeKatex from 'rehype-katex';
|
|
11
|
+
import rehypeRaw from 'rehype-raw';
|
|
12
|
+
import { useMarkdownContext } from "../../Markdown/components/MarkdownProvider";
|
|
13
|
+
import { animatedPlugin } from "../../Markdown/plugins/animated";
|
|
14
|
+
import { rehypeFootnoteLinks } from "../../Markdown/plugins/footnote";
|
|
15
|
+
import { rehypeKatexDir } from "../../Markdown/plugins/katexDir";
|
|
16
|
+
export var useMarkdownRehypePlugins = function useMarkdownRehypePlugins() {
|
|
17
|
+
var _useMarkdownContext = useMarkdownContext(),
|
|
18
|
+
animated = _useMarkdownContext.animated,
|
|
19
|
+
enableLatex = _useMarkdownContext.enableLatex,
|
|
20
|
+
enableCustomFootnotes = _useMarkdownContext.enableCustomFootnotes,
|
|
21
|
+
allowHtml = _useMarkdownContext.allowHtml,
|
|
22
|
+
_useMarkdownContext$r = _useMarkdownContext.rehypePlugins,
|
|
23
|
+
rehypePlugins = _useMarkdownContext$r === void 0 ? [] : _useMarkdownContext$r,
|
|
24
|
+
_useMarkdownContext$r2 = _useMarkdownContext.rehypePluginsAhead,
|
|
25
|
+
rehypePluginsAhead = _useMarkdownContext$r2 === void 0 ? [] : _useMarkdownContext$r2;
|
|
26
|
+
var memoPlugins = useMemo(function () {
|
|
27
|
+
return [allowHtml && rehypeRaw, enableLatex && rehypeKatex, enableLatex && rehypeKatexDir, enableCustomFootnotes && rehypeFootnoteLinks, animated && animatedPlugin].filter(Boolean);
|
|
28
|
+
}, [animated, enableLatex, enableCustomFootnotes, allowHtml]);
|
|
29
|
+
return useMemo(function () {
|
|
30
|
+
return [].concat(_toConsumableArray(rehypePluginsAhead), _toConsumableArray(memoPlugins), _toConsumableArray(rehypePlugins));
|
|
31
|
+
}, [rehypePlugins, memoPlugins, rehypePluginsAhead]);
|
|
32
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
4
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
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); }
|
|
6
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
7
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
|
+
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; }
|
|
9
|
+
import { useMemo } from 'react';
|
|
10
|
+
import remarkBreaks from 'remark-breaks';
|
|
11
|
+
import remarkGfm from 'remark-gfm';
|
|
12
|
+
import remarkMath from 'remark-math';
|
|
13
|
+
import { useMarkdownContext } from "../../Markdown/components/MarkdownProvider";
|
|
14
|
+
import { remarkCustomFootnotes } from "../../Markdown/plugins/footnote";
|
|
15
|
+
export var useMarkdownRemarkPlugins = function useMarkdownRemarkPlugins() {
|
|
16
|
+
var _useMarkdownContext = useMarkdownContext(),
|
|
17
|
+
enableLatex = _useMarkdownContext.enableLatex,
|
|
18
|
+
enableCustomFootnotes = _useMarkdownContext.enableCustomFootnotes,
|
|
19
|
+
_useMarkdownContext$r = _useMarkdownContext.remarkPlugins,
|
|
20
|
+
remarkPlugins = _useMarkdownContext$r === void 0 ? [] : _useMarkdownContext$r,
|
|
21
|
+
_useMarkdownContext$r2 = _useMarkdownContext.remarkPluginsAhead,
|
|
22
|
+
remarkPluginsAhead = _useMarkdownContext$r2 === void 0 ? [] : _useMarkdownContext$r2,
|
|
23
|
+
variant = _useMarkdownContext.variant;
|
|
24
|
+
var isChatMode = variant === 'chat';
|
|
25
|
+
var memoPlugins = useMemo(function () {
|
|
26
|
+
return [enableLatex && remarkMath, enableCustomFootnotes && remarkCustomFootnotes, isChatMode && remarkBreaks].filter(Boolean);
|
|
27
|
+
}, [isChatMode, enableLatex, enableCustomFootnotes]);
|
|
28
|
+
return useMemo(function () {
|
|
29
|
+
return [[remarkGfm, {
|
|
30
|
+
singleTilde: false
|
|
31
|
+
}]].concat(_toConsumableArray(remarkPluginsAhead), _toConsumableArray(memoPlugins), _toConsumableArray(remarkPlugins));
|
|
32
|
+
}, [remarkPlugins, memoPlugins, remarkPluginsAhead]);
|
|
33
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Pluggable } from 'unified';
|
|
2
1
|
/**
|
|
3
2
|
* Cache for storing processed content to avoid redundant processing
|
|
4
3
|
*/
|
|
@@ -11,29 +10,6 @@ export declare const contentCache: Map<string, string>;
|
|
|
11
10
|
* @param value The processed content to store
|
|
12
11
|
*/
|
|
13
12
|
export declare const addToCache: (key: string, value: string) => void;
|
|
14
|
-
/**
|
|
15
|
-
* Plugin configuration options for markdown processing
|
|
16
|
-
*/
|
|
17
|
-
interface PluginOptions {
|
|
18
|
-
allowHtml?: boolean;
|
|
19
|
-
animated?: boolean;
|
|
20
|
-
enableCustomFootnotes?: boolean;
|
|
21
|
-
enableLatex?: boolean;
|
|
22
|
-
isChatMode: boolean;
|
|
23
|
-
rehypePlugins?: Pluggable | Pluggable[];
|
|
24
|
-
remarkPlugins?: Pluggable | Pluggable[];
|
|
25
|
-
remarkPluginsAhead?: Pluggable | Pluggable[];
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Creates remark and rehype plugin lists based on configuration options
|
|
29
|
-
*
|
|
30
|
-
* @param props Plugin configuration options
|
|
31
|
-
* @returns Object containing remark and rehype plugin lists
|
|
32
|
-
*/
|
|
33
|
-
export declare const createPlugins: (props: PluginOptions) => {
|
|
34
|
-
rehypePluginsList: Pluggable[];
|
|
35
|
-
remarkPluginsList: Pluggable[];
|
|
36
|
-
};
|
|
37
13
|
/**
|
|
38
14
|
* Fixes markdown bold syntax by adding space after closing bold markers
|
|
39
15
|
* when followed by non-space characters after symbols
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread 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 _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
-
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; }
|
|
7
|
-
import rehypeKatex from 'rehype-katex';
|
|
8
|
-
import rehypeRaw from 'rehype-raw';
|
|
9
|
-
import remarkBreaks from 'remark-breaks';
|
|
10
|
-
import remarkGfm from 'remark-gfm';
|
|
11
|
-
import remarkMath from 'remark-math';
|
|
12
|
-
import { animatedPlugin } from "../../Markdown/plugins/animated";
|
|
13
|
-
import { rehypeFootnoteLinks, remarkCustomFootnotes } from "../../Markdown/plugins/footnote";
|
|
14
|
-
import { rehypeKatexDir } from "../../Markdown/plugins/katexDir";
|
|
15
1
|
import { preprocessLaTeX } from "./latex";
|
|
16
2
|
|
|
17
3
|
// Cache configuration
|
|
@@ -38,44 +24,6 @@ export var addToCache = function addToCache(key, value) {
|
|
|
38
24
|
contentCache.set(key, value);
|
|
39
25
|
};
|
|
40
26
|
|
|
41
|
-
/**
|
|
42
|
-
* Plugin configuration options for markdown processing
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Creates remark and rehype plugin lists based on configuration options
|
|
47
|
-
*
|
|
48
|
-
* @param props Plugin configuration options
|
|
49
|
-
* @returns Object containing remark and rehype plugin lists
|
|
50
|
-
*/
|
|
51
|
-
export var createPlugins = function createPlugins(props) {
|
|
52
|
-
var allowHtml = props.allowHtml,
|
|
53
|
-
enableLatex = props.enableLatex,
|
|
54
|
-
enableCustomFootnotes = props.enableCustomFootnotes,
|
|
55
|
-
isChatMode = props.isChatMode,
|
|
56
|
-
rehypePlugins = props.rehypePlugins,
|
|
57
|
-
remarkPlugins = props.remarkPlugins,
|
|
58
|
-
remarkPluginsAhead = props.remarkPluginsAhead,
|
|
59
|
-
animated = props.animated;
|
|
60
|
-
|
|
61
|
-
// Normalize plugin arrays
|
|
62
|
-
var normalizedRehypePlugins = Array.isArray(rehypePlugins) ? rehypePlugins : rehypePlugins ? [rehypePlugins] : [];
|
|
63
|
-
var normalizedRemarkPlugins = Array.isArray(remarkPlugins) ? remarkPlugins : remarkPlugins ? [remarkPlugins] : [];
|
|
64
|
-
var normalizedRemarkPluginsAhead = Array.isArray(remarkPluginsAhead) ? remarkPluginsAhead : remarkPluginsAhead ? [remarkPluginsAhead] : [];
|
|
65
|
-
|
|
66
|
-
// Create rehype plugins list
|
|
67
|
-
var rehypePluginsList = [allowHtml && rehypeRaw, enableLatex && rehypeKatex, enableLatex && rehypeKatexDir, enableCustomFootnotes && rehypeFootnoteLinks, animated && animatedPlugin].concat(_toConsumableArray(normalizedRehypePlugins)).filter(Boolean);
|
|
68
|
-
|
|
69
|
-
// Create remark plugins list
|
|
70
|
-
var remarkPluginsList = [].concat(_toConsumableArray(normalizedRemarkPluginsAhead), [enableLatex && remarkMath, [remarkGfm, {
|
|
71
|
-
singleTilde: false
|
|
72
|
-
}], enableCustomFootnotes && remarkCustomFootnotes, isChatMode && remarkBreaks], _toConsumableArray(normalizedRemarkPlugins)).filter(Boolean);
|
|
73
|
-
return {
|
|
74
|
-
rehypePluginsList: rehypePluginsList,
|
|
75
|
-
remarkPluginsList: remarkPluginsList
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
|
|
79
27
|
/**
|
|
80
28
|
* Fixes markdown bold syntax by adding space after closing bold markers
|
|
81
29
|
* when followed by non-space characters after symbols
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/ui",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.7",
|
|
4
4
|
"description": "Lobe UI is an open-source UI component library for building AIGC web apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lobehub",
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"uuid": "^11.1.0"
|
|
106
106
|
},
|
|
107
107
|
"peerDependencies": {
|
|
108
|
-
"antd": "^5.
|
|
108
|
+
"antd": "^5.25.0",
|
|
109
109
|
"framer-motion": "^12.0.0",
|
|
110
110
|
"react": "^19.0.0",
|
|
111
111
|
"react-dom": "^19.0.0"
|