• Settings
    • Locale
    • Change the locale of the datepicker, schedule and client side validation messages.

      Language
      English
      English
      English
      French
      German
      German
      German
      Italian
      Korean
      Spanish
      Catalan
      Dutch
      Portuguese
      Portuguese
      Arabic
      Arabic
      Bulgarian
      Bangla
      Bosnian
      Czech
      Greek
      Estonian
      Persian
      Finnish
      Danish
      Hindi
      Indonesian
      Icelandic
      Croatian
      Japanese
      Hungarian
      Hebrew
      Georgian
      Central Kurdish
      Khmer
      Kyrgyz
      Kazakh
      Lithuanian
      Latvian
      Malay
      Norwegian
      Polish
      Romanian
      Russian
      Slovak
      Slovenian
      Serbian
      Serbian
      Swedish
      Thai
      Turkish
      Ukrainian
      Uzbek
      Vietnamese
      Chinese
      Chinese
  • Resources

MarkdownEditor

MarkdownEditor is a text area replacement for writing beautiful and understandable Markdown. It allows users who may be less experienced with Markdown to use familiar toolbar buttons and shortcuts, and renders the syntax while editing. Based on Easy MDE by Sparksuite, Inc, Jeroen Akkerman.

MarkdownEditor Tag Documentation

Markdown editor component for editing markdown content.

NameTypeRequiredDefaultDescription
id String false generated Unique identifier of the component in a namingContainer.
rendered boolean false true Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding UIComponent false generated An EL expression referring to a server side UIComponent instance in a backing bean.
widgetVar String false generated ('widget_' + componentClientId) Name of the client side widget.
accesskey String false Access key to transfer focus to the input element.
allowBlocks boolean false true Whether to allow blocks to be included when secure=true and the HTML is sanitized.
allowFormatting boolean false true Whether to allow formatting to be included when secure=true and the HTML is sanitized.
allowImages boolean false true Whether to allow images to be included when secure=true and the HTML is sanitized.
allowLinks boolean false true Whether to allow links to be included when secure=true and the HTML is sanitized.
allowMedia boolean false true Whether to allow audio/video to be included when secure=true and the HTML is sanitized.
allowStyles boolean false true Whether to allow styles to be included when secure=true and the HTML is sanitized.
allowTables boolean false true Whether to allow tables to be included when secure=true and the HTML is sanitized.
ariaDescribedBy String false Identifies the element(s) that describe the object, enhancing accessibility.
cols int false 0 Defines the number of columns in the text area.
converter Converter false EL expression resolves to a converter instance or literal converter ID defining a component converter.
converterMessage String false Custom message to display when conversion fails.
dir String false ltr Direction indication for text that does not inherit directionality.
disabled boolean false false Specifies that an element should be disabled.
extender String false The extender to use for the editor.
immediate boolean false false When set true, process validations logic is executed at apply request values phase for this component.
indentWithTabs boolean false true If set true, indent using tabs instead of spaces.
inputmode String false Specifies the type of data expected in the input, aiding virtual keyboards.
label String false A localized user presentable name.
lang String false Specifies the language of the element's content.
lineNumbers boolean false false Whether to show line numbers.
localValueSet boolean false false Indicates whether the local value of the component has been set.
maxHeight String false Maximum height of the editor.
maxlength int false Integer.MIN_VALUE Defines the maximum number of characters allowed in the input.
minHeight String false 300px Minimum height of the editor.
mode String false wysiwyg The mode to use: 'wysiwyg', 'standard', etc.
onblur String false Fires when an element loses focus.
onchange String false Fires when the value of an element has been changed.
onclick String false Fires when a mouse click on the element.
oncontextmenu String false Script to execute when the context menu is triggered.
oncopy String false Script to execute when content is copied from the element.
oncut String false Script to execute when content is cut from the element.
ondblclick String false Fires when a mouse double-click on the element.
ondrag String false Script to execute when an element is dragged.
ondragend String false Script to execute at the end of a drag operation.
ondragenter String false Script to execute when a dragged element enters a valid drop target.
ondragleave String false Script to execute when a dragged element leaves a valid drop target.
ondragover String false Script to execute when a dragged element is over a valid drop target.
ondragstart String false Script to execute at the start of a drag operation.
ondrop String false Script to execute when a dragged element is dropped.
onfocus String false Fires when an element gets focus.
oninput String false Script to execute when the element receives user input.
oninvalid String false Script to execute when the element's value is invalid.
onkeydown String false Fires when a user is pressing a key.
onkeypress String false Fires when a user presses a key.
onkeyup String false Fires when a user releases a key.
onmousedown String false Fires when a mouse button is pressed down on an element.
onmousemove String false Fires when the mouse pointer is moving while it is over an element.
onmouseout String false Fires when the mouse pointer moves out of an element.
onmouseover String false Fires when the mouse pointer moves onto an element.
onmouseup String false Fires when a mouse button is released over an element.
onpaste String false Script to execute when content is pasted into the element.
onreset String false Script to execute when the form is reset.
onscroll String false Script to execute when the element is scrolled.
onsearch String false Script to execute when a search is performed.
onselect String false Script to execute when text is selected.
onwheel String false Script to execute when the mouse wheel is used.
placeholder String false Placeholder text shown when the editor is empty.
promptURLs boolean false false Whether to prompt for URLs when inserting links.
readonly boolean false false Specifies that an input field is read-only.
required boolean false false Marks component as required.
requiredMessage String false Custom message to display when the required validation fails.
role String false Defines the role of the element for accessibility purposes.
rows int false 0 Defines the number of rows in the text area.
secure boolean false true Secure the component with the HTML Sanitizer library on the classpath.
sideBySideFullscreen boolean false true Whether to use side-by-side fullscreen mode.
style String false Specifies an inline CSS style for an element.
styleClass String false Specifies one or more CSS class names for an element.
submittedValue Object false
tabSize Integer false 2 The width of a tab character.
tabindex String false Specifies the tab order of an element.
title String false Specifies extra information about an element (displayed as a tooltip).
toolbar String false The toolbar to use for the editor.
valid boolean false true Indicates whether the input's value is valid.
validator Validator false A method expression referring to a method validating the input.
validatorMessage String false Custom message to display when validation fails.
value Object false Value of the component.
valueChangeListener ValueChangeListener false A method binding expression referring to a method for handling a valuchangeevent.
Tag Documentation Widget Source
Basic Usage

A lightweight, flexible and customizable Markdown editor with a configurable toolbar, side-by-side mode and RTL support. The paste, copy and cut events are sent to the server.

Dialog

A popular use case is an editor inside a PrimeFaces dialog. This example is for both demonstration and testing.

Extender

Use the extender attribute to extend the underlying editor: the function below enables line numbers and custom prompts for links and images (this is the widget, this.cfg its JSON configuration).

Usage


<div class="card">
    <h5>Basic Usage</h5>
    <p>A lightweight, flexible and customizable Markdown editor with a configurable toolbar, side-by-side mode and RTL support. The paste, copy and cut events are sent to the server.</p>
    <h:form id="formBasicUsage">
        <p:messages id="messages" showSummary="true" showDetail="true"/>

        <h:panelGrid columns="2" id="pnlDetails" styleClass="p-4">
            <p:outputLabel value="RTL:" for="@next" styleClass="mr-2"/>
            <p:selectBooleanCheckbox id="chkRtl" value="#{markdownEditorController.rtl}" styleClass="mr-2">
                <p:ajax update="txtMarkdown"/>
            </p:selectBooleanCheckbox>
        </h:panelGrid>

        <pe:markdownEditor id="txtMarkdown" widgetVar="mdeBasic" value="#{markdownEditorController.markdown}"
                           maxHeight="300px" sideBySideFullscreen="false" required="true" mode="sidebyside"
                           dir="#{markdownEditorController.rtl ? 'rtl' : 'ltr'}"
                           toolbar="bold, italic, strikethrough, |, heading-1, heading-2, heading-3,|, code, quote, unordered-list, ordered-list,|, clean-block, link, image, table, horizontal-rule,|, preview, side-by-side, fullscreen, |, guide">
            <p:ajax event="paste" listener="#{markdownEditorController.onPaste}" update="messages"/>
            <p:ajax event="copy" listener="#{markdownEditorController.onCopy}" update="messages"/>
            <p:ajax event="cut" listener="#{markdownEditorController.onCut}" update="messages"/>
        </pe:markdownEditor>

        <p:commandButton value="Submit" actionListener="#{markdownEditorController.submit}" update="txtMarkdown messages"
                         styleClass="mt-4"/>
    </h:form>
</div>

<div class="card">
    <h5>Dialog</h5>
    <p>A popular use case is an editor inside a PrimeFaces dialog. This example is for both demonstration and testing.</p>
    <h:form id="formDialog">
        <h:panelGrid columns="6" id="pnlDetails" styleClass="p-4">
            <p:commandButton value="Open Dialog" type="button" icon="pi pi-external-link" onclick="PF('dlgMarkdown').show()"/>
        </h:panelGrid>

        <p:dialog header="Header" widgetVar="dlgMarkdown" minHeight="40" width="60vw" showEffect="fade" closable="true" closeOnEscape="true" modal="true">
            <pe:markdownEditor id="txtMarkdown" widgetVar="mdeDialog" value="#{markdownEditorController.markdown}"
                               maxHeight="200px" sideBySideFullscreen="false"
                               toolbar="bold, italic, |, guide">
            </pe:markdownEditor>
        </p:dialog>
    </h:form>
</div>

<div class="card">
    <h5>Extender</h5>
    <p>
        Use the <code>extender</code> attribute to extend the underlying editor: the function below enables line numbers
        and custom prompts for links and images (<code>this</code> is the widget, <code>this.cfg</code> its JSON configuration).
    </p>
    <h:form id="formExtender">
        <pe:markdownEditor id="txtMarkdown" widgetVar="mdeExtender" value="#{markdownEditorController.markdown}"
                           maxHeight="200px" toolbar="bold, italic, link, |, guide"
                           extender="editorExtender">
        </pe:markdownEditor>
    </h:form>

    <script type="text/javascript">
        function editorExtender() {
            // this = widget
            // this.cfg = JSON configuration
            this.cfg.lineNumbers = true;
            this.cfg.promptURLs = true;
            this.cfg.promptTexts = {
                image: "Custom prompt for URL:",
                link: "Custom prompt for URL:",
            };
        };
    </script>
</div>