Class Markdown

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.markdown.Markdown
All Implemented Interfaces:
AttachNotifier, DetachNotifier, HasElement, HasSize, HasStyle, Serializable

@Tag("vaadin-markdown") @NpmPackage(value="@vaadin/markdown", version="25.3.0-alpha14") @JsModule("@vaadin/markdown/src/vaadin-markdown.js") public class Markdown extends Component implements HasSize
Markdown is a component for rendering Markdown content. It takes Markdown source as input and renders the corresponding HTML.
Since:
24.8
Author:
Vaadin Ltd
See Also:
  • Constructor Details

    • Markdown

      public Markdown()
      Default constructor. Creates an empty Markdown.
    • Markdown

      public Markdown(String content)
      Creates a Markdown with content.
      Parameters:
      content - the markdown content
      See Also:
    • Markdown

      public Markdown(Signal<String> contentSignal)
      Creates a Markdown with content bound to a signal.
      Parameters:
      contentSignal - the signal providing the markdown content
      Since:
      25.3
      See Also:
  • Method Details

    • setContent

      public void setContent(String content)
      Sets the markdown content.
      Parameters:
      content - the markdown content
    • appendContent

      public void appendContent(String content)
      Appends the markdown content.
      Parameters:
      content - the markdown content to append
    • getContent

      public String getContent()
      Gets the markdown content.
      Returns:
      the markdown content
    • bindContent

      public SignalBinding<String> bindContent(Signal<String> contentSignal)
      Binds the markdown content to the given signal. While the binding is active, calling setContent(String) or appendContent(String) will throw a BindingActiveException.
      Parameters:
      contentSignal - the signal providing the markdown content
      Returns:
      a SignalBinding that can be used to register onChange callbacks
      Since:
      25.3
    • setLineBreaks

      public void setLineBreaks(boolean lineBreaks)
      Sets whether single line breaks ("soft breaks") within a paragraph are rendered as line breaks, the same way chat and message-style Markdown behaves.

      By default, this is false, following the original Markdown specification where single line breaks are ignored and a blank line is required to start a new paragraph.

      Parameters:
      lineBreaks - true to render single line breaks as line breaks, false otherwise
      Since:
      25.3
    • isLineBreaks

      public boolean isLineBreaks()
      Gets whether single line breaks ("soft breaks") within a paragraph are rendered as line breaks.
      Returns:
      true if single line breaks are rendered as line breaks, false otherwise
      Since:
      25.3
    • bindLineBreaks

      public SignalBinding<Boolean> bindLineBreaks(Signal<Boolean> lineBreaksSignal)
      Binds the line breaks state to the given signal. While the binding is active, calling setLineBreaks(boolean) will throw a BindingActiveException. A null signal value is treated as false.
      Parameters:
      lineBreaksSignal - the signal providing the line breaks state, not null
      Returns:
      a SignalBinding that can be used to register onChange callbacks
      Since:
      25.3
    • onAttach

      protected void onAttach(AttachEvent attachEvent)
      Description copied from class: Component
      Called when the component is attached to a UI.

      This method is invoked before the AttachEvent is fired for the component. Make sure to call super.onAttach when overriding this method.

      Overrides:
      onAttach in class Component
      Parameters:
      attachEvent - the attach event