@@ -20,7 +20,12 @@ function lineHightToPadding(lineHeight: string, fontSize: string) {
2020
2121function generateSvgText ( tpc : HTMLElement , tpcStyle : CSSStyleDeclaration , x : number , y : number ) {
2222 const g = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'g' )
23- const content = tpc . childNodes [ 0 ] . textContent
23+ let content = ''
24+ if ( ( tpc as Topic ) . text ) {
25+ content = ( tpc as Topic ) . text . textContent !
26+ } else {
27+ content = tpc . childNodes [ 0 ] . textContent !
28+ }
2429 const lines = content ! . split ( '\n' )
2530 lines . forEach ( ( line , index ) => {
2631 const text = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'text' )
@@ -45,7 +50,12 @@ function generateSvgText(tpc: HTMLElement, tpcStyle: CSSStyleDeclaration, x: num
4550}
4651
4752function generateSvgTextUsingForeignObject ( tpc : HTMLElement , tpcStyle : CSSStyleDeclaration , x : number , y : number ) {
48- const content = tpc . childNodes [ 0 ] . textContent !
53+ let content = ''
54+ if ( ( tpc as Topic ) . text ) {
55+ content = ( tpc as Topic ) . text . textContent !
56+ } else {
57+ content = tpc . childNodes [ 0 ] . textContent !
58+ }
4959 const foreignObject = document . createElementNS ( 'http://www.w3.org/2000/svg' , 'foreignObject' )
5060 setAttributes ( foreignObject , {
5161 x : x + parseInt ( tpcStyle . paddingLeft ) + '' ,
@@ -144,7 +154,7 @@ const generateSvg = (mei: MindElixirInstance, noForiegnObject = false) => {
144154 summaries && g . appendChild ( summaries )
145155
146156 mapDiv . querySelectorAll ( 'me-tpc' ) . forEach ( tpc => {
147- g . appendChild ( convertDivToSvg ( mei , ( tpc as Topic ) . text , noForiegnObject ? false : true ) )
157+ g . appendChild ( convertDivToSvg ( mei , tpc as Topic , noForiegnObject ? false : true ) )
148158 } )
149159 mapDiv . querySelectorAll ( '.tags > span' ) . forEach ( tag => {
150160 g . appendChild ( convertDivToSvg ( mei , tag as HTMLElement ) )
0 commit comments