@lobehub/ui 1.165.1 → 1.165.3
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/index.d.ts +1 -0
- package/es/Markdown/index.js +10 -7
- package/package.json +1 -1
package/es/Markdown/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export interface MarkdownProps extends TypographyProps {
|
|
|
27
27
|
customRender?: (dom: ReactNode, context: {
|
|
28
28
|
text: string;
|
|
29
29
|
}) => ReactNode;
|
|
30
|
+
enableCustomFootnotes?: boolean;
|
|
30
31
|
enableImageGallery?: boolean;
|
|
31
32
|
enableLatex?: boolean;
|
|
32
33
|
enableMermaid?: boolean;
|
package/es/Markdown/index.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 = ["children", "className", "style", "fullFeaturedCodeBlock", "onDoubleClick", "enableLatex", "enableMermaid", "enableImageGallery", "componentProps", "allowHtml", "fontSize", "headerMultiple", "marginMultiple", "showFootnotes", "variant", "lineHeight", "rehypePlugins", "remarkPlugins", "remarkPluginsAhead", "components", "customRender", "citations"];
|
|
4
|
+
var _excluded = ["children", "className", "style", "fullFeaturedCodeBlock", "onDoubleClick", "enableLatex", "enableMermaid", "enableImageGallery", "enableCustomFootnotes", "componentProps", "allowHtml", "fontSize", "headerMultiple", "marginMultiple", "showFootnotes", "variant", "lineHeight", "rehypePlugins", "remarkPlugins", "remarkPluginsAhead", "components", "customRender", "citations"];
|
|
5
5
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
6
|
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."); }
|
|
7
7
|
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); }
|
|
@@ -46,6 +46,7 @@ var Markdown = /*#__PURE__*/memo(function (_ref) {
|
|
|
46
46
|
enableMermaid = _ref$enableMermaid === void 0 ? true : _ref$enableMermaid,
|
|
47
47
|
_ref$enableImageGalle = _ref.enableImageGallery,
|
|
48
48
|
enableImageGallery = _ref$enableImageGalle === void 0 ? true : _ref$enableImageGalle,
|
|
49
|
+
enableCustomFootnotes = _ref.enableCustomFootnotes,
|
|
49
50
|
componentProps = _ref.componentProps,
|
|
50
51
|
allowHtml = _ref.allowHtml,
|
|
51
52
|
fontSize = _ref.fontSize,
|
|
@@ -80,8 +81,10 @@ var Markdown = /*#__PURE__*/memo(function (_ref) {
|
|
|
80
81
|
var isChatMode = variant === 'chat';
|
|
81
82
|
var escapedContent = useMemo(function () {
|
|
82
83
|
if (!enableLatex) return fixMarkdownBold(children);
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
var defaultValue = fixMarkdownBold(escapeMhchem(escapeBrackets(children)));
|
|
85
|
+
if (enableCustomFootnotes) return transformCitations(defaultValue, citations === null || citations === void 0 ? void 0 : citations.length);
|
|
86
|
+
return defaultValue;
|
|
87
|
+
}, [children, enableLatex, enableCustomFootnotes]);
|
|
85
88
|
var memoComponents = useMemo(function () {
|
|
86
89
|
return _objectSpread({
|
|
87
90
|
a: function a(props) {
|
|
@@ -121,13 +124,13 @@ var Markdown = /*#__PURE__*/memo(function (_ref) {
|
|
|
121
124
|
}, [].concat(_toConsumableArray(Object.values(components || {})), _toConsumableArray(Object.values(componentProps || {})), [enableImageGallery, enableMermaid, fullFeaturedCodeBlock], _toConsumableArray(citations || []), [showFootnotes]));
|
|
122
125
|
var innerRehypePlugins = Array.isArray(rehypePlugins) ? rehypePlugins : [rehypePlugins];
|
|
123
126
|
var memoRehypePlugins = useMemo(function () {
|
|
124
|
-
return [allowHtml && rehypeRaw, enableLatex && rehypeKatex, enableLatex && rehypeKatexDir, rehypeFootnoteLinks].concat(_toConsumableArray(innerRehypePlugins)).filter(Boolean);
|
|
125
|
-
}, [allowHtml, enableLatex].concat(_toConsumableArray(innerRehypePlugins)));
|
|
127
|
+
return [allowHtml && rehypeRaw, enableLatex && rehypeKatex, enableLatex && rehypeKatexDir, enableCustomFootnotes && rehypeFootnoteLinks].concat(_toConsumableArray(innerRehypePlugins)).filter(Boolean);
|
|
128
|
+
}, [allowHtml, enableLatex, enableCustomFootnotes].concat(_toConsumableArray(innerRehypePlugins)));
|
|
126
129
|
var innerRemarkPlugins = Array.isArray(remarkPlugins) ? remarkPlugins : [remarkPlugins];
|
|
127
130
|
var innerRemarkPluginsAhead = Array.isArray(remarkPluginsAhead) ? remarkPluginsAhead : [remarkPluginsAhead];
|
|
128
131
|
var memoRemarkPlugins = useMemo(function () {
|
|
129
|
-
return [].concat(_toConsumableArray(innerRemarkPluginsAhead), [remarkGfm, remarkCustomFootnotes, enableLatex && remarkMath, isChatMode && remarkBreaks], _toConsumableArray(innerRemarkPlugins)).filter(Boolean);
|
|
130
|
-
}, [isChatMode, enableLatex].concat(_toConsumableArray(innerRemarkPluginsAhead), _toConsumableArray(innerRemarkPlugins)));
|
|
132
|
+
return [].concat(_toConsumableArray(innerRemarkPluginsAhead), [remarkGfm, enableCustomFootnotes && remarkCustomFootnotes, enableLatex && remarkMath, isChatMode && remarkBreaks], _toConsumableArray(innerRemarkPlugins)).filter(Boolean);
|
|
133
|
+
}, [isChatMode, enableCustomFootnotes, enableLatex].concat(_toConsumableArray(innerRemarkPluginsAhead), _toConsumableArray(innerRemarkPlugins)));
|
|
131
134
|
var defaultDOM = /*#__PURE__*/_jsx(ImageGallery, {
|
|
132
135
|
enable: enableImageGallery,
|
|
133
136
|
children: /*#__PURE__*/_jsx(ReactMarkdown, _objectSpread(_objectSpread({
|