Class JmixMarkdownEditor

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
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, HasAutofocus, Serializable
Direct Known Subclasses:
MarkdownEditor

@Tag("jmix-markdown-editor") @JsModule("./src/markdown-editor/jmix-markdown-editor.js") public class JmixMarkdownEditor extends com.vaadin.flow.component.AbstractSinglePropertyField<JmixMarkdownEditor,String> implements com.vaadin.flow.component.HasLabel, com.vaadin.flow.component.HasHelper, com.vaadin.flow.component.HasPlaceholder, com.vaadin.flow.component.shared.HasValidationProperties, com.vaadin.flow.data.binder.HasValidator<String>, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.shared.HasTooltip, com.vaadin.flow.data.value.HasValueChangeMode, com.vaadin.flow.component.HasAriaLabel, com.vaadin.flow.component.Focusable<JmixMarkdownEditor>, com.vaadin.flow.component.shared.HasThemeVariant<MarkdownEditorVariant>, HasAutofocus
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
    Modifier and Type
    Class
    Description
    static class 
    Internationalization properties for JmixMarkdownEditor.
    static class 
    Event fired when the editor switches between Edit and Preview mode.

    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<?>>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected com.vaadin.flow.data.value.ValueChangeMode
     
    protected com.vaadin.flow.data.binder.Validator<String>
     
     
    protected com.vaadin.flow.component.shared.internal.ValidationController<JmixMarkdownEditor,String>
     
    protected int
     

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

    AUTOFOCUS_PROPERTY_NAME

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

    DEFAULT_CHANGE_TIMEOUT
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an empty JmixMarkdownEditor.
    Constructs an empty JmixMarkdownEditor with the given label.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.vaadin.flow.shared.Registration
    addModeChangedListener(com.vaadin.flow.component.ComponentEventListener<JmixMarkdownEditor.ModeChangedEvent> listener)
    Adds a listener that is notified whenever the editor mode changes between Edit and Preview.
    protected void
     
    com.vaadin.flow.data.binder.Validator<String>
     
    Gets the internationalization object previously set for this component.
    protected String
     
    Returns the current mode of this editor.
    com.vaadin.flow.data.value.ValueChangeMode
    Gets current value change mode of the component.
    int
    Returns the currently set timeout, for how often HasValue.ValueChangeEvents are triggered when the ValueChangeMode is set to ValueChangeMode.LAZY, or ValueChangeMode.TIMEOUT.
    boolean
    Alias for HasValueAndElement.isRequiredIndicatorVisible()
    protected void
    onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
     
    protected void
    runBeforeClientResponse(com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.component.UI> command)
     
    void
    Sets the internationalization object for this component.
    protected void
     
    void
    setManualValidation(boolean enabled)
     
    void
    Sets the editor mode.
    void
    setRequired(boolean required)
    Alias for HasValueAndElement.setRequiredIndicatorVisible(boolean).
    void
    setValueChangeMode(com.vaadin.flow.data.value.ValueChangeMode valueChangeMode)
    Sets new value change mode for the component.
    void
    setValueChangeTimeout(int valueChangeTimeout)
    Sets how often HasValue.ValueChangeEvents are triggered when the ValueChangeMode is set to ValueChangeMode.LAZY, or ValueChangeMode.TIMEOUT.
    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, setPresentationValue, setSynchronizedEvent

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

    addValueChangeListener, bindValue, getEmptyValue, getValue, isEmpty, setModelValue, 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 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.shared.HasValidationProperties

    getErrorMessage, isInvalid, setErrorMessage, setInvalid

    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, setRequiredIndicatorVisible
  • Field Details

    • currentMode

      protected com.vaadin.flow.data.value.ValueChangeMode currentMode
    • valueChangeTimeout

      protected int valueChangeTimeout
    • i18n

    • defaultValidator

      protected com.vaadin.flow.data.binder.Validator<String> defaultValidator
    • validationController

      protected com.vaadin.flow.component.shared.internal.ValidationController<JmixMarkdownEditor,String> validationController
  • Constructor Details

    • JmixMarkdownEditor

      public JmixMarkdownEditor()
      Constructs an empty JmixMarkdownEditor.
    • JmixMarkdownEditor

      public JmixMarkdownEditor(String label)
      Constructs an empty JmixMarkdownEditor with the given label.
      Parameters:
      label - the text to set as the label
  • Method Details

    • getDefaultValidator

      public com.vaadin.flow.data.binder.Validator<String> getDefaultValidator()
      Specified by:
      getDefaultValidator in interface com.vaadin.flow.data.binder.HasValidator<String>
    • setManualValidation

      public void setManualValidation(boolean enabled)
      Specified by:
      setManualValidation in interface com.vaadin.flow.component.HasValidation
    • getValueChangeMode

      public com.vaadin.flow.data.value.ValueChangeMode getValueChangeMode()
      Gets current value change mode of the component.
      Specified by:
      getValueChangeMode in interface com.vaadin.flow.data.value.HasValueChangeMode
      Returns:
      current value change mode of the component, or null if the value is not synchronized
    • setValueChangeMode

      public void setValueChangeMode(com.vaadin.flow.data.value.ValueChangeMode valueChangeMode)
      Sets new value change mode for the component.
      Specified by:
      setValueChangeMode in interface com.vaadin.flow.data.value.HasValueChangeMode
      Parameters:
      valueChangeMode - new value change mode, or null to disable the value synchronization
    • getValueChangeTimeout

      public int getValueChangeTimeout()
      Returns the currently set timeout, for how often HasValue.ValueChangeEvents are triggered when the ValueChangeMode is set to ValueChangeMode.LAZY, or ValueChangeMode.TIMEOUT.
      Specified by:
      getValueChangeTimeout in interface com.vaadin.flow.data.value.HasValueChangeMode
      Returns:
      the timeout in milliseconds of how often HasValue.ValueChangeEvents are triggered.
    • setValueChangeTimeout

      public void setValueChangeTimeout(int valueChangeTimeout)
      Sets how often HasValue.ValueChangeEvents are triggered when the ValueChangeMode is set to ValueChangeMode.LAZY, or ValueChangeMode.TIMEOUT.
      Specified by:
      setValueChangeTimeout in interface com.vaadin.flow.data.value.HasValueChangeMode
      Parameters:
      valueChangeTimeout - the timeout in milliseconds of how often HasValue.ValueChangeEvents are triggered.
    • applyChangeTimeout

      protected void applyChangeTimeout()
    • setRequired

      public void setRequired(boolean required)
      Alias for HasValueAndElement.setRequiredIndicatorVisible(boolean).
      Parameters:
      required - true to make the field required, false otherwise
    • isRequired

      public boolean isRequired()
      Alias for HasValueAndElement.isRequiredIndicatorVisible()
      Returns:
      true if the field is required, false otherwise
    • onAttach

      protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
      Overrides:
      onAttach in class com.vaadin.flow.component.Component
    • getI18n

      Gets the internationalization object previously set for this component.
      Returns:
      the i18n object, or null if none has been set
    • setI18n

      public void setI18n(JmixMarkdownEditor.JmixMarkdownEditorI18n i18n)
      Sets the internationalization object for this component.
      Parameters:
      i18n - the i18n object, not null
    • getMode

      @Synchronize(property="mode", value="mode-changed") public MarkdownEditorMode getMode()
      Returns the current mode of this editor.
      Returns:
      the current MarkdownEditorMode, never null
    • setMode

      public void setMode(MarkdownEditorMode mode)
      Sets the editor mode.
      Parameters:
      mode - the mode to set, not null
    • addModeChangedListener

      public com.vaadin.flow.shared.Registration addModeChangedListener(com.vaadin.flow.component.ComponentEventListener<JmixMarkdownEditor.ModeChangedEvent> listener)
      Adds a listener that is notified whenever the editor mode changes between Edit and Preview.
      Parameters:
      listener - the listener to add, not null
      Returns:
      a handle that can be used to remove the listener
    • validate

      protected void validate()
      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.
    • setI18nWithJS

      protected void setI18nWithJS()
    • runBeforeClientResponse

      protected void runBeforeClientResponse(com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.component.UI> command)
    • getI18nErrorMessage

      protected String getI18nErrorMessage(Function<JmixMarkdownEditor.JmixMarkdownEditorI18n,String> getter)