diff --git a/richtextfx/src/main/java/org/fxmisc/richtext/model/ReadOnlyStyledDocument.java b/richtextfx/src/main/java/org/fxmisc/richtext/model/ReadOnlyStyledDocument.java index 7516c632f..d6533c202 100644 --- a/richtextfx/src/main/java/org/fxmisc/richtext/model/ReadOnlyStyledDocument.java +++ b/richtextfx/src/main/java/org/fxmisc/richtext/model/ReadOnlyStyledDocument.java @@ -127,6 +127,9 @@ public static ReadOnlyStyledDocument fromString(String * @param The type of the style of individual segments. */ public static ReadOnlyStyledDocument fromSegment(SEG segment, PS paragraphStyle, S style, SegmentOps segmentOps) { + if ( segment instanceof String && segmentOps instanceof TextOps ) { + return fromString( (String) segment, paragraphStyle, style, (TextOps) segmentOps ); + } Paragraph content = new Paragraph(paragraphStyle, segmentOps, segment, style); List> res = Collections.singletonList(content); return new ReadOnlyStyledDocument<>(res);