Top Description Fields Constructors Methods
org.jabref.htmltonode

public Class HtmlView

extends VBox
Class Inheritance
Imports
java.util.Optional, javafx.beans.property.ObjectProperty, .SimpleObjectProperty, .SimpleStringProperty, .StringProperty, javafx.scene.layout.VBox, org.jabref.htmltonode.internal.TextSelection, org.jspecify.annotations.Nullable

A small pane that renders an HTML string as JavaFX nodes — the drop-in content for the ScrollPane that JabRef's PreviewViewer already is (instead of a WebView).

Not a live browser: re-renders whenever htmlProperty() or optionsProperty() changes. Must be used on the JavaFX application thread, like any other node.

Field Summary

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

Constructor Summary

AccessConstructor and Description
public
HtmlView()

Creates an empty view with HtmlRenderOptions#defaults().

public
HtmlView(@Nullable String
the initial HTML content; null is treated as empty
html
)

Creates a view showing html with HtmlRenderOptions#defaults().

Method Summary

Modifier and TypeMethod and Description
public final void
clearSelection()

Clears the mouse text selection.

public final String
getHtml()

Returns: the current HTML content; never null

public final HtmlRenderOptions
getOptions()

Returns: the current rendering options; never null

public final Optional<String>
getSelectedText()

Returns: the text currently selected with the mouse, if any

public final StringProperty

Returns:

the html property
htmlProperty
()

The HTML content of this view.

public final boolean
isPressOnSelection()

Returns: whether the current mouse press started on an existing selection — drag-and-drop consumers should only drag the content in that case, otherwise dragging extends the text selection

public final ObjectProperty<HtmlRenderOptions>

Returns:

the options property
optionsProperty
()

The rendering options of this view.

private void
private Optional<TextSelection>
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 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.VBox:
alignmentPropertyclearConstraintscomputeMinHeightcomputeMinWidthcomputePrefHeightcomputePrefWidthfillWidthPropertygetAlignmentgetClassCssMetaDatagetContentBiasgetCssMetaDatagetMargingetSpacinggetVgrowisFillWidthlayoutChildrenrequestLayoutsetAlignmentsetFillWidthsetMarginsetSpacingsetVgrowspacingProperty

Field Detail

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

Constructor Detail

HtmlViewback to summary
public HtmlView()

Creates an empty view with HtmlRenderOptions#defaults().

HtmlViewback to summary
public HtmlView(@Nullable String html)

Creates a view showing html with HtmlRenderOptions#defaults().

Parameters
html:@Nullable String

the initial HTML content; null is treated as empty

Method Detail

clearSelectionback to summary
public final void clearSelection()

Clears the mouse text selection.

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

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

the text currently selected with the mouse, if any

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()
Returns:boolean

whether the current mouse press started on an existing selection — drag-and-drop consumers should only drag the content in that case, otherwise dragging extends the text 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()
selectionback to summary
private Optional<TextSelection> selection()
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()

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)