11import { Link } from '@inertiajs/react' ;
22import type { ReactNode } from 'react' ;
3+ import AppWordmark from '@/components/app-wordmark' ;
34import { UserPreview } from '@/components/user-preview' ;
45import { typedProse } from '@/lib/code' ;
56import { shortenUrl } from '@/lib/urls' ;
@@ -145,6 +146,26 @@ function withPasteis(text: string, pasteisMode: boolean): ReactNode {
145146 ) ;
146147}
147148
149+ function withWordmarks ( text : string , pasteisMode : boolean ) : ReactNode [ ] {
150+ return text
151+ . split (
152+ / (?< ! [ \p{ L} \p{ M} \p{ N} _ . / - ] ) ( \/ d e v \/ n u l l ) (? ! [ \p{ L} \p{ M} \p{ N} _ / - ] ) / u,
153+ )
154+ . map ( ( part , index ) =>
155+ index % 2 === 0 ? (
156+ withPasteis ( part , pasteisMode )
157+ ) : (
158+ < span
159+ key = { `wordmark-${ index } ` }
160+ title = { part }
161+ className = "font-semibold tracking-tight whitespace-nowrap"
162+ >
163+ < AppWordmark />
164+ </ span >
165+ ) ,
166+ ) ;
167+ }
168+
148169function withMentions (
149170 text : string ,
150171 offset : number ,
@@ -156,7 +177,7 @@ function withMentions(
156177
157178 for ( const match of text . matchAll ( mentionPattern ) ) {
158179 parts . push (
159- withPasteis ( text . slice ( position , match . index ) , pasteisMode ) ,
180+ ... withWordmarks ( text . slice ( position , match . index ) , pasteisMode ) ,
160181 isStatic ? (
161182 match [ 0 ]
162183 ) : (
@@ -178,7 +199,7 @@ function withMentions(
178199 position = match . index + match [ 0 ] . length ;
179200 }
180201
181- parts . push ( withPasteis ( text . slice ( position ) , pasteisMode ) ) ;
202+ parts . push ( ... withWordmarks ( text . slice ( position ) , pasteisMode ) ) ;
182203
183204 return parts ;
184205}
0 commit comments