@@ -59,7 +59,7 @@ const DEFAULT_RENDER_OPTIONS = {
5959 customAttributes : { } ,
6060 customStyles : { } ,
6161 supportHtml : false ,
62- preserveWhitespace : true
62+ preserveWhitespace : true ,
6363} ;
6464
6565/**
@@ -179,11 +179,15 @@ export function renderTextToElement(element, text, options = {}) {
179179 // Don't override critical multiline styles if text is multiline
180180 if ( textContent . includes ( '\n' ) && opts . applyStyles ) {
181181 if ( property === 'whiteSpace' || property === 'white-space' ) {
182- console . warn ( 'renderTextToElement: Ignoring whiteSpace override for multiline text' ) ;
182+ console . warn (
183+ 'renderTextToElement: Ignoring whiteSpace override for multiline text'
184+ ) ;
183185 continue ;
184186 }
185187 if ( property === 'wordBreak' || property === 'word-break' ) {
186- console . warn ( 'renderTextToElement: Ignoring wordBreak override for multiline text' ) ;
188+ console . warn (
189+ 'renderTextToElement: Ignoring wordBreak override for multiline text'
190+ ) ;
187191 continue ;
188192 }
189193 }
@@ -396,12 +400,32 @@ export class MultilineText {
396400 // Store original dimensions for layout recalculation
397401 const originalHeight = element . clientHeight ;
398402
399- // Use the new static rendering function with plugin configuration
400- renderTextToElement ( element , node . topic , {
401- clearElement : true ,
402- applyStyles : true ,
403- supportHtml : this . jm . view . opts . support_html || false
404- } ) ;
403+ // Check if we have custom node render function
404+ const hasCustomRender =
405+ this . jm . view . opts . custom_node_render &&
406+ typeof this . jm . view . opts . custom_node_render === 'function' ;
407+
408+ let customRendered = false ;
409+
410+ if ( hasCustomRender ) {
411+ // Try custom render first
412+ try {
413+ customRendered = this . jm . view . opts . custom_node_render ( this . jm , element , node ) ;
414+ } catch ( error ) {
415+ console . error ( 'Multiline text plugin: Error in custom_node_render' , error ) ;
416+ customRendered = false ;
417+ }
418+ }
419+
420+ // If custom render didn't handle it, use our multiline logic
421+ if ( ! customRendered ) {
422+ // Use the new static rendering function with plugin configuration
423+ renderTextToElement ( element , node . topic , {
424+ clearElement : true ,
425+ applyStyles : true ,
426+ supportHtml : this . jm . view . opts . support_html || false ,
427+ } ) ;
428+ }
405429
406430 // Check if height changed and trigger layout update if needed
407431 const newHeight = element . clientHeight ;
@@ -442,7 +466,7 @@ export class MultilineText {
442466 renderMultilineText ( element , text , options = { } ) {
443467 // Prepare options with jsMind configuration
444468 const defaultOptions = {
445- supportHtml : this . jm . view . opts . support_html || false
469+ supportHtml : this . jm . view . opts . support_html || false ,
446470 } ;
447471
448472 // Merge with provided options
@@ -493,7 +517,7 @@ export class MultilineText {
493517 createMultilineElement ( text , options = { } ) {
494518 // Prepare options with jsMind configuration
495519 const defaultOptions = {
496- supportHtml : this . jm . view . opts . support_html || false
520+ supportHtml : this . jm . view . opts . support_html || false ,
497521 } ;
498522
499523 // Merge with provided options
0 commit comments