@@ -67,22 +67,6 @@ function calcTooltipPos(anchorRect: DOMRect, el: HTMLDivElement | null): Tooltip
6767 return { top, left, maxWidth, maxHeight : Math . max ( maxHeight , 80 ) } ;
6868}
6969
70- // ── 描述行解析:key: value 高亮 ──────────────────────────────────
71-
72- const KV_RE = / ^ ( [ ^ : ] + ) : \s * ( [ \s \S ] + ) $ / ;
73-
74- function renderDescLine ( line : string , accent : string ) : React . ReactNode {
75- const m = line . match ( KV_RE ) ;
76- if ( m ) {
77- return (
78- < span >
79- < span style = { { color : accent , fontWeight : 600 } } > { m [ 1 ] } </ span >
80- < span > : { m [ 2 ] } </ span >
81- </ span >
82- ) ;
83- }
84- return line ;
85- }
8670
8771// ── 问号图标 ─────────────────────────────────────────────────────
8872
@@ -170,9 +154,9 @@ export const Toolbar: React.FC<ToolbarProps> = ({
170154 if ( ! description ) setShowDesc ( false ) ;
171155 } , [ description ] ) ;
172156
173- const descLines = description
174- ? description . replace ( / \\ n / g, '\n' ) . split ( '\n' ) . filter ( ( l ) => l . trim ( ) )
175- : [ ] ;
157+ const descHtml = description
158+ ? description . replace ( / \\ n / g, '\n' ) . replace ( / \n / g , '<br>' )
159+ : '' ;
176160
177161 const handleThemeToggle = ( ) => {
178162 const next = isDark ? 'light' : 'dark' ;
@@ -211,7 +195,7 @@ export const Toolbar: React.FC<ToolbarProps> = ({
211195
212196
213197 { /* 脚本说明按钮 */ }
214- { descLines . length > 0 && (
198+ { descHtml && (
215199 < ToolbarButton
216200 ref = { descBtnRef }
217201 label = {
@@ -316,7 +300,7 @@ export const Toolbar: React.FC<ToolbarProps> = ({
316300 { toolbarExtra }
317301
318302 { /* 脚本说明 Tooltip(fixed 定位,脱离滚动容器) */ }
319- { showDesc && tipPos && descLines . length > 0 && (
303+ { showDesc && tipPos && descHtml && (
320304 < div
321305 ref = { tipRef }
322306 style = { {
@@ -338,13 +322,8 @@ export const Toolbar: React.FC<ToolbarProps> = ({
338322 boxShadow : '0 4px 16px rgba(0,0,0,0.3)' ,
339323 pointerEvents : 'auto' ,
340324 } }
341- >
342- { descLines . map ( ( line , i ) => (
343- < div key = { i } style = { { marginBottom : i < descLines . length - 1 ? 4 : 0 } } >
344- { renderDescLine ( line , colors . accent ) }
345- </ div >
346- ) ) }
347- </ div >
325+ dangerouslySetInnerHTML = { { __html : descHtml } }
326+ />
348327 ) }
349328 </ div >
350329 ) ;
0 commit comments