@lobehub/ui 1.168.19 → 1.168.21

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.
@@ -80,7 +80,7 @@ export var useHighlight = function useHighlight(text, lang, enableTransformer) {
80
80
  // 长文本使用 hash
81
81
  var hash = text.length < MD5_LENGTH_THRESHOLD ? text : Md5.hashStr(text);
82
82
  return [matchedLanguage, isDarkMode ? 'd' : 'l', hash].join('-');
83
- }, [matchedLanguage, isDarkMode]);
83
+ }, [text, matchedLanguage, isDarkMode]);
84
84
 
85
85
  // 使用SWR获取高亮HTML
86
86
  return useSWR(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
@@ -35,13 +35,12 @@ export var useMermaid = function useMermaid(id, content) {
35
35
  _useState2 = _slicedToArray(_useState, 2),
36
36
  validContent = _useState2[0],
37
37
  setValidContent = _useState2[1];
38
- console.log(id, content);
39
38
 
40
39
  // 为长内容生成哈希键
41
40
  var cacheKey = useMemo(function () {
42
41
  var hash = content.length < MD5_LENGTH_THRESHOLD ? content : Md5.hashStr(content);
43
- return "mermaid-".concat(hash);
44
- }, [content]);
42
+ return "mermaid-".concat(id, "-").concat(hash);
43
+ }, [content, id]);
45
44
  return useSWR(cacheKey, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
46
45
  var mermaidInstance, isValid, _yield$mermaidInstanc, svg;
47
46
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -69,7 +68,7 @@ export var useMermaid = function useMermaid(id, content) {
69
68
  case 10:
70
69
  isValid = _context.sent;
71
70
  if (!isValid) {
72
- _context.next = 22;
71
+ _context.next = 21;
73
72
  break;
74
73
  }
75
74
  _context.next = 14;
@@ -77,27 +76,26 @@ export var useMermaid = function useMermaid(id, content) {
77
76
  case 14:
78
77
  _yield$mermaidInstanc = _context.sent;
79
78
  svg = _yield$mermaidInstanc.svg;
80
- console.log(svg);
81
79
  setValidContent(svg);
82
80
  // 缓存验证结果
83
81
  mermaidCache.set(cacheKey, true);
84
82
  return _context.abrupt("return", svg);
85
- case 22:
83
+ case 21:
86
84
  throw new Error('Mermaid 语法无效');
87
- case 23:
88
- _context.next = 29;
85
+ case 22:
86
+ _context.next = 28;
89
87
  break;
90
- case 25:
91
- _context.prev = 25;
88
+ case 24:
89
+ _context.prev = 24;
92
90
  _context.t0 = _context["catch"](2);
93
91
  console.error('Mermaid 解析错误:', _context.t0);
94
92
  // 返回最近一次有效的内容,或空字符串
95
93
  return _context.abrupt("return", validContent || '');
96
- case 29:
94
+ case 28:
97
95
  case "end":
98
96
  return _context.stop();
99
97
  }
100
- }, _callee, null, [[2, 25]]);
98
+ }, _callee, null, [[2, 24]]);
101
99
  })), {
102
100
  dedupingInterval: 3000,
103
101
  errorRetryCount: 2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.168.19",
3
+ "version": "1.168.21",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",