@lobehub/ui 2.7.1 → 2.7.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.
|
@@ -49,11 +49,29 @@ var SyntaxMermaid = /*#__PURE__*/memo(function (_ref) {
|
|
|
49
49
|
}, [blobUrl]);
|
|
50
50
|
useEffect(function () {
|
|
51
51
|
if (isLoading || !data) return;
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
var finalSvgString = data;
|
|
53
|
+
|
|
54
|
+
// 修复Firefox点击预览mermaid图时宽高为0导致不显示的异常
|
|
55
|
+
if (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]);
|