@lobehub/ui 2.7.1 → 2.7.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.
@@ -49,11 +49,29 @@ var SyntaxMermaid = /*#__PURE__*/memo(function (_ref) {
49
49
  }, [blobUrl]);
50
50
  useEffect(function () {
51
51
  if (isLoading || !data) return;
52
- // 创建Blob对象
53
- var svgBlob = new Blob([data], {
52
+ var finalSvgString = data;
53
+
54
+ // 修复Firefox点击预览mermaid图时宽高为0导致不显示的异常
55
+ if (typeof window !== 'undefined' && typeof navigator !== 'undefined' && navigator.userAgent.includes('Firefox')) {
56
+ var parser = new DOMParser();
57
+ var svgDoc = parser.parseFromString(data, 'image/svg+xml');
58
+ var svgElement = svgDoc.documentElement;
59
+ if (svgElement && svgElement.hasAttribute('viewBox')) {
60
+ var viewBox = svgElement.getAttribute('viewBox');
61
+ var viewBoxParts = viewBox.split(' ');
62
+ if (Array.isArray(viewBoxParts) && viewBoxParts.length === 4) {
63
+ svgElement.setAttribute('width', viewBoxParts[2]);
64
+ svgElement.setAttribute('height', viewBoxParts[3]);
65
+ }
66
+ finalSvgString = new XMLSerializer().serializeToString(svgDoc);
67
+ }
68
+ }
69
+
70
+ // // 创建Blob对象
71
+ var svgBlob = new Blob([finalSvgString], {
54
72
  type: 'image/svg+xml'
55
73
  });
56
- // 创建并保存Blob URL
74
+ // // 创建并保存Blob URL
57
75
  var url = URL.createObjectURL(svgBlob);
58
76
  setBlobUrl(url);
59
77
  }, [isLoading, data]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "2.7.1",
3
+ "version": "2.7.3",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",