Class MarkdownEditor

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<JmixMarkdownEditor,String>
com.vaadin.flow.component.AbstractSinglePropertyField<JmixMarkdownEditor,String>
io.jmix.flowui.kit.component.markdowneditor.JmixMarkdownEditor
io.jmix.flowui.component.markdowneditor.MarkdownEditor
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.BlurNotifier<JmixMarkdownEditor>, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.Focusable<JmixMarkdownEditor>, com.vaadin.flow.component.FocusNotifier<JmixMarkdownEditor>, com.vaadin.flow.component.HasAriaLabel, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasHelper, com.vaadin.flow.component.HasLabel, com.vaadin.flow.component.HasPlaceholder, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasTheme, com.vaadin.flow.component.HasValidation, com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<JmixMarkdownEditor,String>,String>, com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<JmixMarkdownEditor,String>,String>, com.vaadin.flow.component.shared.HasThemeVariant<MarkdownEditorVariant>, com.vaadin.flow.component.shared.HasTooltip, com.vaadin.flow.component.shared.HasValidationProperties, com.vaadin.flow.data.binder.HasValidator<String>, com.vaadin.flow.data.value.HasValueChangeMode, HasRequired, SupportsStatusChangeHandler<MarkdownEditor>, SupportsValidation<String>, SupportsValueSource<String>, HasAutofocus, Serializable, org.springframework.beans.factory.Aware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware

public class MarkdownEditor extends JmixMarkdownEditor implements SupportsValueSource<String>, SupportsValidation<String>, SupportsStatusChangeHandler<MarkdownEditor>, HasRequired, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean
A markdown editor field component that supports editing and rendered preview.

The component provides an Edit/Preview tab bar, a formatting toolbar with common markdown actions and keyboard shortcuts, and renders the preview using the built-in vaadin-markdown component.

See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from class io.jmix.flowui.kit.component.markdowneditor.JmixMarkdownEditor

    JmixMarkdownEditor.JmixMarkdownEditorI18n, JmixMarkdownEditor.ModeChangedEvent

    Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField

    com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,V>

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier

    com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier

    com.vaadin.flow.component.FocusNotifier.FocusEvent<C extends com.vaadin.flow.component.Component>

    Nested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue

    com.vaadin.flow.component.HasValue.ValueChangeEvent<V>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>>

    Nested classes/interfaces inherited from interface io.jmix.flowui.component.SupportsStatusChangeHandler

    SupportsStatusChangeHandler.StatusContext<C extends com.vaadin.flow.component.Component>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.springframework.context.ApplicationContext
     
     

    Fields inherited from class io.jmix.flowui.kit.component.markdowneditor.JmixMarkdownEditor

    currentMode, defaultValidator, i18n, validationController, valueChangeTimeout

    Fields inherited from interface io.jmix.flowui.kit.component.HasAutofocus

    AUTOFOCUS_PROPERTY_NAME

    Fields inherited from interface io.jmix.flowui.component.HasRequired

    PROPERTY_REQUIRED

    Fields inherited from interface com.vaadin.flow.data.value.HasValueChangeMode

    DEFAULT_CHANGE_TIMEOUT

    Fields inherited from interface io.jmix.flowui.component.SupportsValidation

    PROPERTY_ERROR_MESSAGE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.vaadin.flow.shared.Registration
    addValidator(Validator<? super String> validator)
    Adds a validator to the list of validators for the component.
    void
     
     
    void
    Executes all registered validators against the current value of the component.
    @Nullable String
     
    @Nullable String
    Returns the custom validation message to be displayed if the component is marked as required and the validation fails due to a missing value.
    @Nullable ValueSource<String>
    Returns the current ValueSource associated with this component.
    protected void
     
    protected void
     
    boolean
     
    boolean
     
    void
    setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
     
    void
    setErrorMessage(@Nullable String errorMessage)
     
    void
    setInvalid(boolean invalid)
    Sets invalid state to the field considering result of field validation.
    protected void
    setModelValue(String newModelValue, boolean fromClient)
     
    protected void
    setPresentationValue(String newPresentationValue)
     
    void
    setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
     
    void
    setRequiredMessage(@Nullable String requiredMessage)
    Sets a message that will be displayed or logged when a required field or input is not provided.
    void
    Sets a callback to be used to handle component status changes, e.g.
    void
    setValueSource(@Nullable ValueSource<String> valueSource)
    Sets a ValueSource for this component, allowing it to bind its value to a specified data source.
    protected void
    Validates the current value against the field constraints and updates the invalid state and error message accordingly.

    Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField

    getSynchronizationRegistration, hasValidValue, setSynchronizedEvent

    Methods inherited from class com.vaadin.flow.component.AbstractField

    addValueChangeListener, bindValue, getEmptyValue, getValue, setValue, valueEquals

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisible

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.BlurNotifier

    addBlurListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.Focusable

    addFocusShortcut, blur, focus, focus, getTabIndex, setTabIndex

    Methods inherited from interface com.vaadin.flow.component.FocusNotifier

    addFocusListener

    Methods inherited from interface com.vaadin.flow.component.HasAriaLabel

    getAriaLabel, getAriaLabelledBy, setAriaLabel, setAriaLabelledBy

    Methods inherited from interface io.jmix.flowui.kit.component.HasAutofocus

    isAutofocus, setAutofocus

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.HasEnabled

    bindEnabled, isEnabled, setEnabled

    Methods inherited from interface com.vaadin.flow.component.HasHelper

    bindHelperText, getHelperComponent, getHelperText, setHelperComponent, setHelperText

    Methods inherited from interface com.vaadin.flow.component.HasLabel

    getLabel, setLabel

    Methods inherited from interface com.vaadin.flow.component.HasPlaceholder

    bindPlaceholder, getPlaceholder, setPlaceholder

    Methods inherited from interface io.jmix.flowui.component.HasRequired

    isRequired, setRequired

    Methods inherited from interface com.vaadin.flow.component.HasSize

    bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName

    Methods inherited from interface com.vaadin.flow.component.HasTheme

    addThemeName, addThemeNames, bindThemeName, bindThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName

    Methods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant

    addThemeVariants, bindThemeVariant, removeThemeVariants, setThemeVariant, setThemeVariants, setThemeVariants

    Methods inherited from interface com.vaadin.flow.component.shared.HasTooltip

    getTooltip, setTooltipMarkdown, setTooltipText

    Methods inherited from interface com.vaadin.flow.component.HasValidation

    setManualValidation

    Methods inherited from interface com.vaadin.flow.data.binder.HasValidator

    addValidationStatusChangeListener

    Methods inherited from interface com.vaadin.flow.component.HasValue

    clear, getOptionalValue

    Methods inherited from interface com.vaadin.flow.component.HasValueAndElement

    bindReadOnly, bindRequiredIndicatorVisible, isReadOnly, isRequiredIndicatorVisible, setReadOnly
  • Field Details

  • Constructor Details

    • MarkdownEditor

      public MarkdownEditor()
  • Method Details

    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • initComponent

      protected void initComponent()
    • initI18n

      protected void initI18n()
    • setModelValue

      protected void setModelValue(String newModelValue, boolean fromClient)
      Overrides:
      setModelValue in class com.vaadin.flow.component.AbstractField<JmixMarkdownEditor,String>
    • setPresentationValue

      protected void setPresentationValue(String newPresentationValue)
      Overrides:
      setPresentationValue in class com.vaadin.flow.component.AbstractSinglePropertyField<JmixMarkdownEditor,String>
    • setRequiredIndicatorVisible

      public void setRequiredIndicatorVisible(boolean requiredIndicatorVisible)
      Specified by:
      setRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<JmixMarkdownEditor,String>,String>
      Specified by:
      setRequiredIndicatorVisible in interface com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<JmixMarkdownEditor,String>,String>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<JmixMarkdownEditor,String>,String>
      Overrides:
      isEmpty in class com.vaadin.flow.component.AbstractField<JmixMarkdownEditor,String>
    • getRequiredMessage

      public @Nullable String getRequiredMessage()
      Description copied from interface: HasRequired
      Returns the custom validation message to be displayed if the component is marked as required and the validation fails due to a missing value.
      Specified by:
      getRequiredMessage in interface HasRequired
      Returns:
      the required message set for the component, or null if no message is defined
    • setRequiredMessage

      public void setRequiredMessage(@Nullable String requiredMessage)
      Description copied from interface: HasRequired
      Sets a message that will be displayed or logged when a required field or input is not provided.
      Specified by:
      setRequiredMessage in interface HasRequired
      Parameters:
      requiredMessage - the message to be set for required fields. If null, the default message or no message will be used.
    • getErrorMessage

      public @Nullable String getErrorMessage()
      Specified by:
      getErrorMessage in interface com.vaadin.flow.component.HasValidation
      Specified by:
      getErrorMessage in interface com.vaadin.flow.component.shared.HasValidationProperties
      Specified by:
      getErrorMessage in interface SupportsValidation<String>
    • setErrorMessage

      public void setErrorMessage(@Nullable String errorMessage)
      Specified by:
      setErrorMessage in interface com.vaadin.flow.component.HasValidation
      Specified by:
      setErrorMessage in interface com.vaadin.flow.component.shared.HasValidationProperties
      Specified by:
      setErrorMessage in interface SupportsValidation<String>
    • setStatusChangeHandler

      public void setStatusChangeHandler(@Nullable Consumer<SupportsStatusChangeHandler.StatusContext<MarkdownEditor>> handler)
      Description copied from interface: SupportsStatusChangeHandler
      Sets a callback to be used to handle component status changes, e.g. validation messages set by HasValidation.setErrorMessage(String).
      Specified by:
      setStatusChangeHandler in interface SupportsStatusChangeHandler<MarkdownEditor>
      Parameters:
      handler - a handler to set
    • addValidator

      public com.vaadin.flow.shared.Registration addValidator(Validator<? super String> validator)
      Description copied from interface: SupportsValidation
      Adds a validator to the list of validators for the component. The provided validator will be used to validate the value of the component during validation execution.
      Specified by:
      addValidator in interface SupportsValidation<String>
      Parameters:
      validator - the validator to be added; should not be null
      Returns:
      a Registration object that allows removing the added validator
    • executeValidators

      public void executeValidators() throws ValidationException
      Description copied from interface: SupportsValidation
      Executes all registered validators against the current value of the component. If any of the validators fail, a ValidationException is thrown to indicate the failure. The exact behavior and order of validation depend on the validators added.
      Specified by:
      executeValidators in interface SupportsValidation<String>
      Throws:
      ValidationException - if validation fails for one or more validators
    • validate

      protected void validate()
      Description copied from class: JmixMarkdownEditor
      Validates the current value against the field constraints and updates the invalid state and error message accordingly. Has no effect when manual validation is enabled.
      Overrides:
      validate in class JmixMarkdownEditor
    • isInvalid

      public boolean isInvalid()
      Specified by:
      isInvalid in interface com.vaadin.flow.component.HasValidation
      Specified by:
      isInvalid in interface com.vaadin.flow.component.shared.HasValidationProperties
    • setInvalid

      public void setInvalid(boolean invalid)
      Description copied from interface: SupportsValidation
      Sets invalid state to the field considering result of field validation.
      • Invalid - false and validation passed - false = field is invalid
      • Invalid - false and validation passed - true = field is valid
      • Invalid - true and validation passed - false = field is invalid
      • Invalid - true and validation passed - true = field is invalid
      Specified by:
      setInvalid in interface com.vaadin.flow.component.HasValidation
      Specified by:
      setInvalid in interface com.vaadin.flow.component.shared.HasValidationProperties
      Specified by:
      setInvalid in interface SupportsValidation<String>
      Parameters:
      invalid - whether field should be invalid
    • getValueSource

      public @Nullable ValueSource<String> getValueSource()
      Description copied from interface: SupportsValueSource
      Returns the current ValueSource associated with this component.
      Specified by:
      getValueSource in interface SupportsValueSource<String>
      Returns:
      the associated ValueSource, or null if no value source is set
    • setValueSource

      public void setValueSource(@Nullable ValueSource<String> valueSource)
      Description copied from interface: SupportsValueSource
      Sets a ValueSource for this component, allowing it to bind its value to a specified data source.
      Specified by:
      setValueSource in interface SupportsValueSource<String>
      Parameters:
      valueSource - the ValueSource to be associated with this component, or null to remove the current association
    • createFieldDelegate

      protected FieldDelegate<MarkdownEditor,String,String> createFieldDelegate()