@lobehub/ui 2.12.0 → 2.12.2
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/Markdown/Markdown.js +20 -17
- package/es/Markdown/components/MarkdownProvider.d.ts +2 -5
- package/es/Markdown/components/MarkdownProvider.js +4 -2
- package/es/Markdown/type.d.ts +1 -0
- package/es/hooks/useMarkdown/useMarkdownComponents.js +6 -3
- package/es/mdx/mdxComponents/Section.d.ts +1 -0
- package/es/mdx/mdxComponents/Section.js +3 -1
- package/package.json +1 -1
package/es/Markdown/Markdown.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 = ["ref", "children", "className", "style", "fullFeaturedCodeBlock", "onDoubleClick", "animated", "enableLatex", "enableMermaid", "enableImageGallery", "enableCustomFootnotes", "enableGithubAlert", "enableStream", "componentProps", "allowHtml", "borderRadius", "fontSize", "headerMultiple", "marginMultiple", "variant", "reactMarkdownProps", "lineHeight", "rehypePlugins", "remarkPlugins", "remarkPluginsAhead", "components", "customRender", "citations"];
|
|
4
|
+
var _excluded = ["ref", "children", "className", "style", "fullFeaturedCodeBlock", "onDoubleClick", "animated", "enableLatex", "enableMermaid", "enableImageGallery", "enableCustomFootnotes", "enableGithubAlert", "enableStream", "componentProps", "rehypePluginsAhead", "allowHtml", "borderRadius", "fontSize", "headerMultiple", "marginMultiple", "variant", "reactMarkdownProps", "lineHeight", "rehypePlugins", "remarkPlugins", "remarkPluginsAhead", "components", "customRender", "showFootnotes", "citations"];
|
|
5
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
7
|
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; }
|
|
@@ -37,6 +37,7 @@ var Markdown = /*#__PURE__*/memo(function (props) {
|
|
|
37
37
|
_props$enableStream = props.enableStream,
|
|
38
38
|
enableStream = _props$enableStream === void 0 ? true : _props$enableStream,
|
|
39
39
|
componentProps = props.componentProps,
|
|
40
|
+
rehypePluginsAhead = props.rehypePluginsAhead,
|
|
40
41
|
allowHtml = props.allowHtml,
|
|
41
42
|
_props$borderRadius = props.borderRadius,
|
|
42
43
|
borderRadius = _props$borderRadius === void 0 ? props.variant === 'chat' ? 4 : undefined : _props$borderRadius,
|
|
@@ -57,6 +58,8 @@ var Markdown = /*#__PURE__*/memo(function (props) {
|
|
|
57
58
|
_props$components = props.components,
|
|
58
59
|
components = _props$components === void 0 ? {} : _props$components,
|
|
59
60
|
customRender = props.customRender,
|
|
61
|
+
_props$showFootnotes = props.showFootnotes,
|
|
62
|
+
showFootnotes = _props$showFootnotes === void 0 ? true : _props$showFootnotes,
|
|
60
63
|
citations = props.citations,
|
|
61
64
|
rest = _objectWithoutProperties(props, _excluded);
|
|
62
65
|
var _useStyles = useStyles(),
|
|
@@ -120,22 +123,22 @@ var Markdown = /*#__PURE__*/memo(function (props) {
|
|
|
120
123
|
style: style
|
|
121
124
|
}, rest), {}, {
|
|
122
125
|
children: /*#__PURE__*/_jsx(MarkdownProvider, {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
126
|
+
allowHtml: allowHtml,
|
|
127
|
+
animated: delayedAnimated,
|
|
128
|
+
citations: citations,
|
|
129
|
+
componentProps: componentProps,
|
|
130
|
+
components: components,
|
|
131
|
+
enableCustomFootnotes: enableCustomFootnotes,
|
|
132
|
+
enableGithubAlert: enableGithubAlert,
|
|
133
|
+
enableLatex: enableLatex,
|
|
134
|
+
enableMermaid: enableMermaid,
|
|
135
|
+
fullFeaturedCodeBlock: fullFeaturedCodeBlock,
|
|
136
|
+
rehypePlugins: rehypePlugins,
|
|
137
|
+
rehypePluginsAhead: rehypePluginsAhead,
|
|
138
|
+
remarkPlugins: remarkPlugins,
|
|
139
|
+
remarkPluginsAhead: remarkPluginsAhead,
|
|
140
|
+
showFootnotes: showFootnotes,
|
|
141
|
+
variant: variant,
|
|
139
142
|
children: /*#__PURE__*/_jsx(Render, {
|
|
140
143
|
enableStream: enableStream,
|
|
141
144
|
reactMarkdownProps: reactMarkdownProps,
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
2
|
import type { SyntaxMarkdownProps } from '../type';
|
|
3
3
|
export type MarkdownContentConfig = Omit<SyntaxMarkdownProps, 'children' | 'reactMarkdownProps'>;
|
|
4
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
|
-
}>;
|
|
5
|
+
export declare const MarkdownProvider: import("react").NamedExoticComponent<PropsWithChildren<MarkdownContentConfig>>;
|
|
9
6
|
export declare const useMarkdownContext: () => MarkdownContentConfig;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
var _excluded = ["children"];
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
3
6
|
import { createContext, memo, use } from 'react';
|
|
4
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
8
|
export var MarkdownContext = /*#__PURE__*/createContext({});
|
|
6
9
|
export var MarkdownProvider = /*#__PURE__*/memo(function (_ref) {
|
|
7
10
|
var children = _ref.children,
|
|
8
|
-
|
|
9
|
-
config = _ref$config === void 0 ? {} : _ref$config;
|
|
11
|
+
config = _objectWithoutProperties(_ref, _excluded);
|
|
10
12
|
return /*#__PURE__*/_jsx(MarkdownContext, {
|
|
11
13
|
value: config,
|
|
12
14
|
children: children
|
package/es/Markdown/type.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ export interface SyntaxMarkdownProps {
|
|
|
42
42
|
rehypePluginsAhead?: Pluggable[];
|
|
43
43
|
remarkPlugins?: Pluggable[];
|
|
44
44
|
remarkPluginsAhead?: Pluggable[];
|
|
45
|
+
showFootnotes?: boolean;
|
|
45
46
|
variant?: 'default' | 'chat';
|
|
46
47
|
}
|
|
47
48
|
export interface MarkdownProps extends SyntaxMarkdownProps, Omit<TypographyProps, 'children'> {
|
|
@@ -31,7 +31,8 @@ export var useMarkdownComponents = function useMarkdownComponents() {
|
|
|
31
31
|
citations = _useMarkdownContext.citations,
|
|
32
32
|
componentProps = _useMarkdownContext.componentProps,
|
|
33
33
|
enableMermaid = _useMarkdownContext.enableMermaid,
|
|
34
|
-
fullFeaturedCodeBlock = _useMarkdownContext.fullFeaturedCodeBlock
|
|
34
|
+
fullFeaturedCodeBlock = _useMarkdownContext.fullFeaturedCodeBlock,
|
|
35
|
+
showFootnotes = _useMarkdownContext.showFootnotes;
|
|
35
36
|
var memoA = useCallback(
|
|
36
37
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
37
38
|
function (_ref) {
|
|
@@ -60,8 +61,10 @@ export var useMarkdownComponents = function useMarkdownComponents() {
|
|
|
60
61
|
function (_ref4) {
|
|
61
62
|
var node = _ref4.node,
|
|
62
63
|
props = _objectWithoutProperties(_ref4, _excluded4);
|
|
63
|
-
return /*#__PURE__*/_jsx(Section, _objectSpread({
|
|
64
|
-
|
|
64
|
+
return /*#__PURE__*/_jsx(Section, _objectSpread({
|
|
65
|
+
showFootnotes: showFootnotes
|
|
66
|
+
}, props));
|
|
67
|
+
}, [showFootnotes]);
|
|
65
68
|
var memoKbd = useCallback(function (_ref5) {
|
|
66
69
|
var children = _ref5.children;
|
|
67
70
|
return /*#__PURE__*/_jsx(Hotkey, {
|
|
@@ -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 = ["children"];
|
|
4
|
+
var _excluded = ["children", "showFootnotes"];
|
|
5
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
7
|
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,9 +13,11 @@ import Footnotes from "../../Markdown/components/Footnotes";
|
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
var Section = function Section(_ref) {
|
|
15
15
|
var children = _ref.children,
|
|
16
|
+
showFootnotes = _ref.showFootnotes,
|
|
16
17
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
17
18
|
// 说明是脚注
|
|
18
19
|
if (rest['data-footnotes']) {
|
|
20
|
+
if (!showFootnotes) return null;
|
|
19
21
|
return /*#__PURE__*/_jsx(Footnotes, _objectSpread(_objectSpread({}, rest), {}, {
|
|
20
22
|
children: children
|
|
21
23
|
}));
|