@lobehub/ui 2.1.3 → 2.1.5
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.
|
@@ -41,8 +41,7 @@ var SyntaxMarkdown = /*#__PURE__*/memo(function (_ref2) {
|
|
|
41
41
|
enableLatex = _ref2$enableLatex === void 0 ? true : _ref2$enableLatex,
|
|
42
42
|
_ref2$enableMermaid = _ref2.enableMermaid,
|
|
43
43
|
enableMermaid = _ref2$enableMermaid === void 0 ? true : _ref2$enableMermaid,
|
|
44
|
-
|
|
45
|
-
enableImageGallery = _ref2$enableImageGall === void 0 ? true : _ref2$enableImageGall,
|
|
44
|
+
enableImageGallery = _ref2.enableImageGallery,
|
|
46
45
|
enableCustomFootnotes = _ref2.enableCustomFootnotes,
|
|
47
46
|
componentProps = _ref2.componentProps,
|
|
48
47
|
allowHtml = _ref2.allowHtml,
|
|
@@ -68,14 +68,14 @@ var createComponentFactories = function createComponentFactories(params) {
|
|
|
68
68
|
* Optimized version with better memoization and performance
|
|
69
69
|
*/
|
|
70
70
|
export var useMarkdown = function useMarkdown(_ref) {
|
|
71
|
+
var _componentProps$highl2, _componentProps$merma2;
|
|
71
72
|
var fullFeaturedCodeBlock = _ref.fullFeaturedCodeBlock,
|
|
72
73
|
animated = _ref.animated,
|
|
73
74
|
_ref$enableLatex = _ref.enableLatex,
|
|
74
75
|
enableLatex = _ref$enableLatex === void 0 ? true : _ref$enableLatex,
|
|
75
76
|
_ref$enableMermaid = _ref.enableMermaid,
|
|
76
77
|
enableMermaid = _ref$enableMermaid === void 0 ? true : _ref$enableMermaid,
|
|
77
|
-
|
|
78
|
-
enableImageGallery = _ref$enableImageGalle === void 0 ? true : _ref$enableImageGalle,
|
|
78
|
+
enableImageGallery = _ref.enableImageGallery,
|
|
79
79
|
enableCustomFootnotes = _ref.enableCustomFootnotes,
|
|
80
80
|
componentProps = _ref.componentProps,
|
|
81
81
|
allowHtml = _ref.allowHtml,
|
|
@@ -111,18 +111,41 @@ export var useMarkdown = function useMarkdown(_ref) {
|
|
|
111
111
|
rehypePluginsList = _useMemo.rehypePluginsList,
|
|
112
112
|
remarkPluginsList = _useMemo.remarkPluginsList;
|
|
113
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
|
+
|
|
114
137
|
// Memoize the factory parameters to prevent recreating component factories
|
|
115
138
|
var factoryParams = useMemo(function () {
|
|
116
139
|
return {
|
|
117
140
|
animated: animated || false,
|
|
118
141
|
// Ensure animated is always a boolean
|
|
119
142
|
citations: citations,
|
|
120
|
-
componentProps:
|
|
143
|
+
componentProps: stableComponentProps,
|
|
121
144
|
enableMermaid: enableMermaid,
|
|
122
145
|
fullFeaturedCodeBlock: fullFeaturedCodeBlock,
|
|
123
146
|
showFootnotes: showFootnotes
|
|
124
147
|
};
|
|
125
|
-
}, [animated, citations,
|
|
148
|
+
}, [animated, citations, stableComponentProps, enableMermaid, fullFeaturedCodeBlock, showFootnotes]);
|
|
126
149
|
|
|
127
150
|
// Create component factories once and reuse them
|
|
128
151
|
var componentFactories = useMemo(function () {
|
package/es/mdx/Mdx/index.js
CHANGED
|
@@ -46,8 +46,7 @@ var Mdx = /*#__PURE__*/memo(function (_ref) {
|
|
|
46
46
|
style = _ref.style,
|
|
47
47
|
_ref$fullFeaturedCode = _ref.fullFeaturedCodeBlock,
|
|
48
48
|
fullFeaturedCodeBlock = _ref$fullFeaturedCode === void 0 ? true : _ref$fullFeaturedCode,
|
|
49
|
-
|
|
50
|
-
enableImageGallery = _ref$enableImageGalle === void 0 ? true : _ref$enableImageGalle,
|
|
49
|
+
enableImageGallery = _ref.enableImageGallery,
|
|
51
50
|
_ref$enableLatex = _ref.enableLatex,
|
|
52
51
|
enableLatex = _ref$enableLatex === void 0 ? true : _ref$enableLatex,
|
|
53
52
|
_ref$enableMermaid = _ref.enableMermaid,
|
|
@@ -22,7 +22,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
22
22
|
var useStyles = createStyles(function (_ref) {
|
|
23
23
|
var css = _ref.css;
|
|
24
24
|
return {
|
|
25
|
-
container: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n overflow: hidden;\n margin-block:
|
|
25
|
+
container: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n overflow: hidden;\n margin-block: 0.5em;\n border-radius: calc(var(--lobe-markdown-border-radius) * 1px);\n box-shadow: 0 0 0 1px var(--lobe-markdown-border-color) inset;\n "])))
|
|
26
26
|
};
|
|
27
27
|
});
|
|
28
28
|
export var Pre = function Pre(_ref2) {
|