Krajee

Advanced Usage Example 3

Thankful to Krajee! BUY A COFFEEor to get more out of us.

Creating your own custom buttons and custom actions, labels, icons, and titles. The toolbarFooterL has been changed in this example to include buttons to generate LEFT arrow and RIGHT arrow markup. In addition, this example also shows how you can configure the markdown-it library plugin options. For example, you can allow HTML code to be typed in the editor by setting html setting to true within markdownItOptions.

When allowing html input, you must purify the HTML output to prevent XSS attack.

The purify.min.js is the DomPurify plugin by cure53. It is required to be loaded before markdown-editor.min.js if you wish to purify your HTML for HTML content preview and is called when purifyHtml is set to true. This is normally only needed when you set allow html to true within markdownItOptions .

<!-- Include DOM purify plugin to purify HTML output. This must be loaded before markdown-editor.js. -->
<script src="https://cdn.jsdelivr.net/gh/kartik-v/krajee-markdown-editor@1.0.0/plugins/purify/purify.min.js" type="text/javascript"></script>

Note, the demo example(s) uses:

  • this as the raw input source for the markdown textarea.

  • these assets loaded on the page in the order mentioned.

Tip

Not seeing the updated content on this page! Hard refresh your browser to clean cache for this page (e.g. SHIFT-F5 on Windows Chrome)


Example
Code
<textarea id="editor-a3" name="editor-a3" class="form-control" rows="15">
{RAW MARKDOWN DATA}
</textarea>

<script type="text/javascript">
$('#editor-a3').markdownEditor({
    toolbarFooterL: [
        ['arrowLeft', 'arrowRight']
    ],
    buttonActions: {
        arrowLeft: {before: '<--', after: ' ', 'default': ''},
        arrowRight: {before: '-->', after: ' ', 'default': ''}
    },
    buttonTitles: {
        arrowLeft: 'Left Arrow',
        arrowRight: 'Right Arrow'
    },
    icons: {
        arrowLeft: '<span class="fas fa-fw fa-arrow-left"></span>',
        arrowRight: '<span class="fas fa-fw fa-arrow-right"></span>'
    },
    markdownItOptions: {
        html: true
    },
    purifyHtml: true
});
</script>

Note

You can now visit the Krajee Webtips Q & A forum for searching OR asking questions OR helping programmers with answers on these extensions and plugins. For asking a question click here. Select the appropriate question category (i.e. Krajee Plugins) and choose this current page plugin in the question related to field.

The comments and discussion section below are intended for generic discussions or feedback for this plugin. Developers may not be able to search or lookup here specific questions or tips on usage for this plugin.

 
visitors to Krajee Jquery Plugins since 22-May-2017