Class MarkdownMessage
java.lang.Object
com.vaadin.flow.component.Component
org.vaadin.firitin.components.messagelist.MarkdownMessage
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,Serializable
@Tag("vaadin-message")
public class MarkdownMessage
extends com.vaadin.flow.component.Component
implements com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasSize
A wrapper for vaadin-message web component, that supports Markdown
formatting and appending content dynamically to the element. Typical
usecase: LLM chatbots slowly giving you the answer.
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionMarkdownMessage(String name) Constructs a new MarkdownMessages, without initial content.MarkdownMessage(String markdown, String name) Constructs a new MarkdownMessages, with initial content.MarkdownMessage(String markdown, String name, LocalDateTime timestamp) Constructs a new MarkdownMessages, with initial content.MarkdownMessage(String markdown, String name, MarkdownMessage.Color avatarColor) Constructs a new MarkdownMessages, with initial content.MarkdownMessage(String name, LocalDateTime timestamp) Constructs a new MarkdownMessages, without initial content.MarkdownMessage(String name, LocalDateTime timestamp, MarkdownMessage.Color color) Constructs a new MarkdownMessages with all the bells and whistles, without initial content.MarkdownMessage(String name, MarkdownMessage.Color avatarColor) Constructs a new MarkdownMessages, without initial content. -
Method Summary
Modifier and TypeMethodDescriptionvoidappendMarkdown(String markdownSnippet) Directly adds markdown formatted text to message part.protected voidappendMarkdown(String markdownSnippet, boolean uiAccess) voidappendMarkdownAsync(String markdownSnippet) Adds markdown formatted text to message part.protected voidDeprecated.not necessarily supported by the implementationprotected org.vaadin.firitin.components.messagelist.MarkdownMessage.MarkdownStrategycom.vaadin.flow.component.UIgetUi()booleanprotected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) voidsetAutoScroll(boolean autoScroll) voidvoidsetMarkdown(String markdown) protected voidsetMarkdown(String markdown, boolean uiAccess) voidsetUserColorIndex(int index) voidMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Constructor Details
-
MarkdownMessage
Constructs a new MarkdownMessages with all the bells and whistles, without initial content. Add that later withappendMarkdownAsync(String).- Parameters:
name- the name of the usertimestamp- time of the messagecolor- the color used for user avatar
-
MarkdownMessage
Constructs a new MarkdownMessages, without initial content. Add that later withappendMarkdownAsync(String).- Parameters:
name- the name of the user
-
MarkdownMessage
Constructs a new MarkdownMessages, without initial content. Add that later withappendMarkdownAsync(String).- Parameters:
name- the name of the usertimestamp- the timestamp of the message
-
MarkdownMessage
Constructs a new MarkdownMessages, without initial content. Add that later withappendMarkdownAsync(String).- Parameters:
name- the name of the useravatarColor- the avatar color
-
MarkdownMessage
Constructs a new MarkdownMessages, with initial content. You can add more text later withappendMarkdownAsync(String).- Parameters:
markdown- the initial content as markdown formatter textname- the name of the useravatarColor- the color of the avatar
-
MarkdownMessage
Constructs a new MarkdownMessages, with initial content. You can add more text later withappendMarkdownAsync(String).- Parameters:
markdown- the initial content as markdown formatter textname- the name of the user
-
MarkdownMessage
Constructs a new MarkdownMessages, with initial content. You can add more text later withappendMarkdownAsync(String).- Parameters:
markdown- the initial content as markdown formatted textname- the name of the usertimestamp- the timestamp of the message
-
-
Method Details
-
setAvatarColor
-
setUserColorIndex
public void setUserColorIndex(int index) -
getMarkdown
Deprecated.not necessarily supported by the implementation- Returns:
- current markdown content
-
getMarkdownStrategy
protected org.vaadin.firitin.components.messagelist.MarkdownMessage.MarkdownStrategy getMarkdownStrategy() -
useFlexmarkJava
public void useFlexmarkJava() -
setMarkdown
-
setMarkdown
-
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
getUi
public com.vaadin.flow.component.UI getUi() -
appendMarkdown
Directly adds markdown formatted text to message part. Note, that this method should not be called from any other but Vaadin UI thread. Consider using theappendMarkdownAsync(String)version in case the new text is coming from a background thread.- Parameters:
markdownSnippet- the new markdown formatted text snippet
-
appendMarkdownAsync
Adds markdown formatted text to message part. This method takes care of synchronization withUI.access(Command), so it is safe to call this directly from a background thread.- Parameters:
markdownSnippet- the new markdown formatted text snippet
-
appendMarkdown
-
isAutoScroll
public boolean isAutoScroll() -
setAutoScroll
public void setAutoScroll(boolean autoScroll) -
doAutoScroll
protected void doAutoScroll()
-