@@ -193,12 +193,15 @@ function suppressFocusRingOnClick({target}) {
193193}
194194
195195function interceptClick ( event ) {
196- const el = event . target . closest ( '[data-cmd=note]' ) ;
197- if ( el ) {
196+ let note = event . target . closest ( '[data-cmd=note]' ) ;
197+ if ( note ) {
198198 event . preventDefault ( ) ;
199+ note = tooltips . get ( note ) || note . title ;
199200 messageBox . show ( {
200201 className : 'note center-dialog' ,
201- contents : tHTML ( tooltips . get ( el ) || el . title ) ,
202+ contents : note . includes ( '<' ) ? tHTML ( note ) :
203+ note . includes ( '\n' ) ? $create ( 'div' , note . split ( '\n' ) . map ( line => $create ( 'p' , line ) ) ) :
204+ note ,
202205 buttons : [ t ( 'confirmClose' ) ] ,
203206 } ) ;
204207 }
@@ -210,15 +213,16 @@ function interceptClick(event) {
210213function splitLongTooltips ( ) {
211214 for ( const el of $$ ( '[title]' ) ) {
212215 tooltips . set ( el , el . title ) ;
213- el . title = el . title . replace ( / \s * < \/ ? [ ^ > ] + > \s * / g, ' ' ) ; // strip html tags
216+ // Strip html tags but allow <invalid-html-tags> which we use to emphasize stuff
217+ el . title = el . title . replace ( / ( \n \s * ) ? < \/ ? [ a - z ] + [ ^ > ] * > ( \n \s * ) ? / g, ' ' ) ;
214218 if ( el . title . length < 50 ) {
215219 continue ;
216220 }
217221 const newTitle = el . title
218222 . split ( '\n' )
219223 . map ( s => s . replace ( / ( [ . ? ! ] \s + | [ . 。 ? ! ] \s * | .{ 50 , 60 } , ) \s + / gu, '$1\n' ) )
220224 . map ( s => s . replace ( / ( .{ 50 , 80 } (? = .{ 40 , } ) ) \s + / gu, '$1\n' ) )
221- . join ( '\n' ) ;
225+ . join ( '\n\n ' ) ;
222226 if ( newTitle !== el . title ) el . title = newTitle ;
223227 }
224228}
0 commit comments