Top Description Fields Constructors Methods
org.jabref.htmltonode.rich

public Class RichHtmlView

extends StackPane
Class Inheritance
Imports
java.util.Optional, javafx.beans.property.ObjectProperty, .SimpleObjectProperty, .SimpleStringProperty, .StringProperty, javafx.geometry.Pos, javafx.scene.layout.StackPane, org.jabref.htmltonode.HtmlRenderOptions, .HtmlToNode, jfx.incubator.scene.control.richtext.RichTextArea, .SelectionSegment, .TextPos, jfx.incubator.scene.control.richtext.model.StyledTextModel, org.jspecify.annotations.Nullable

A pane rendering an HTML string into a read-only RichTextArea — like org.jabref.htmltonode.HtmlView, but with native text selection, caret navigation, and accessibility. The area scrolls itself; do not wrap this view in a ScrollPane.

Re-renders whenever htmlProperty() or optionsProperty() changes. Must be used on the JavaFX application thread. Requires the jfx.incubator.richtext module at runtime.

Field Summary

Modifier and TypeField and Description
private final RichTextArea
private final StringProperty
private final ObjectProperty<HtmlRenderOptions>

Constructor Summary

AccessConstructor and Description
public
RichHtmlView()

Creates an empty view with HtmlRenderOptions#defaults().

Method Summary

Modifier and TypeMethod and Description
public final String
getHtml()

Returns: the current HTML content; never null

public final HtmlRenderOptions
getOptions()

Returns: the current rendering options; never null

public final RichTextArea
getRichTextArea()

Returns: the backing control, e.g. for copy actions, printing, or selection access

public final Optional<String>
getSelectedText()

Returns: the selected text, joined with line breaks at paragraph boundaries; empty if nothing is selected

public final StringProperty

Returns:

the html property
htmlProperty
()

The HTML content of this view.

public final boolean
isPressOnSelection(double
the horizontal screen coordinate of a mouse press
screenX
,
double
the vertical screen coordinate of a mouse press
screenY
)

Returns: whether the given position lies on the current text selection — only then a drag gesture should drag the selected content instead of extending the selection

public final ObjectProperty<HtmlRenderOptions>

Returns:

the options property
optionsProperty
()

The rendering options of this view.

private void
public final void
setHtml(@Nullable String
the HTML content to render; null is treated as empty
newHtml
)

public final void
setOptions(@Nullable HtmlRenderOptions
the rendering options; null restores HtmlRenderOptions#defaults()
newOptions
)

public final void
setUseContentHeight(boolean
whether the area should size to its content
on
)

Sizes the area to its content so that an enclosing pane handles the scrolling — by default the area scrolls itself.

public final String

Returns:

the plain text; see HtmlToNode#toPlainText(String)
toPlainText
()

Extracts readable plain text from the current content, e.g. for "copy as text".

Inherited from javafx.scene.layout.StackPane:
alignmentPropertyclearConstraintscomputeMinHeightcomputeMinWidthcomputePrefHeightcomputePrefWidthgetAlignmentgetAlignmentgetClassCssMetaDatagetContentBiasgetCssMetaDatagetMarginlayoutChildrenrequestLayoutsetAlignmentsetAlignmentsetMargin

Field Detail

areaback to summary
private final RichTextArea area
htmlback to summary
private final StringProperty html
optionsback to summary
private final ObjectProperty<HtmlRenderOptions> options

Constructor Detail

RichHtmlViewback to summary
public RichHtmlView()

Creates an empty view with HtmlRenderOptions#defaults().

Method Detail

getHtmlback to summary
public final String getHtml()
Returns:String

the current HTML content; never null

getOptionsback to summary
public final HtmlRenderOptions getOptions()
Returns:HtmlRenderOptions

the current rendering options; never null

getRichTextAreaback to summary
public final RichTextArea getRichTextArea()
Returns:RichTextArea

the backing control, e.g. for copy actions, printing, or selection access

getSelectedTextback to summary
public final Optional<String> getSelectedText()
Returns:Optional<String>

the selected text, joined with line breaks at paragraph boundaries; empty if nothing is selected

htmlPropertyback to summary
public final StringProperty htmlProperty()

The HTML content of this view. Setting a new value re-renders. Never null.

Returns:StringProperty

the html property

isPressOnSelectionback to summary
public final boolean isPressOnSelection(double screenX, double screenY)
Parameters
screenX:double

the horizontal screen coordinate of a mouse press

screenY:double

the vertical screen coordinate of a mouse press

Returns:boolean

whether the given position lies on the current text selection — only then a drag gesture should drag the selected content instead of extending the selection

optionsPropertyback to summary
public final ObjectProperty<HtmlRenderOptions> optionsProperty()

The rendering options of this view. Setting a new value re-renders. Never null.

Returns:ObjectProperty<HtmlRenderOptions>

the options property

rerenderback to summary
private void rerender()
setHtmlback to summary
public final void setHtml(@Nullable String newHtml)
Parameters
newHtml:@Nullable String

the HTML content to render; null is treated as empty

setOptionsback to summary
public final void setOptions(@Nullable HtmlRenderOptions newOptions)
Parameters
newOptions:@Nullable HtmlRenderOptions

the rendering options; null restores HtmlRenderOptions#defaults()

setUseContentHeightback to summary
public final void setUseContentHeight(boolean on)

Sizes the area to its content so that an enclosing pane handles the scrolling — by default the area scrolls itself.

Parameters
on:boolean

whether the area should size to its content

toPlainTextback to summary
public final String toPlainText()

Extracts readable plain text from the current content, e.g. for "copy as text".

Returns:String

the plain text; see HtmlToNode#toPlainText(String)