Skip to content

JavaScript HTML Editor

A lightweight WYSIWYG JavaScript HTML editor is available with a few native features.

  1. The HTML tags are filtered on the paste action.
  2. JavaScript events for easy integration
  3. Remote URL parser and snippet integrated object.
  4. Custom toolbar
  5. Integrated file and image dropzone
  6. Extensions
MethodDescription
setData()Set new data to the editor.
getData()Get the current data.
reset()Clear the content of the editor.
destroy()Destroy the editor.
PropertyDescription
value: stringInitial HTML value
snippet: objectSnippet object
toolbar: boolean | objectTrue for the default toolbar, or a items of a customized toolbar.
remoteParser: stringA URL for the remote URL/image parser.
parseURL: booleanParse URL inside the editor to create a snippet.
filterPaste: booleanFilter all content onpaste
dropZone: booleanAllow images or files to be dropped in the editor.
acceptFiles: booleanAccept PDF on the editor.
acceptImages: booleanAccept images on the editor.
dropAsAttachment: booleanWhen images are dropped, they are included as attachement.
maxFileSize: numberMax filesize in bytes.
border: booleanAdd borders to the editor.
padding: booleanAdd padding to the editor.
maxHeight: numberMax height for the editor.
focus: booleanFocus on the content after the data is loaded.
placeholder: stringContent placeholder
extensions: objectThe extensions object.
EventDescription
onclickWhen a click happens on the editor.
(element: HTMLElement, instance: Object, event: Object) => void
onfocusWhen the editor is focused.
(element: HTMLElement, instance: Object, currentValue: string) => void
onblurWhen the editor is blurred.
(element: HTMLElement, instance: Object, currentValue: string) => void
onloadA method is execute when the modal is closed.
(element: HTMLElement, instance: Object, editor: HTMLElement) => void
onkeyupWhen a new key from the keyboard is released.
(element: HTMLElement, instance: Object, event: Object) => void
onkeydownWhen a new key from the keyboard is pressed.
(element: HTMLElement, instance: Object, event: Object) => void

<html>
<script src="https://jsuites.net/v6/jsuites.js"></script>
<link rel="stylesheet" href="https://jsuites.net/v6/jsuites.css" type="text/css" />

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons" />

<div id="editor" style="width: 480px;"></div>

<p><input type='button' value='Get data' id="btn"></p>

<script>
let editor = jSuites.editor(document.getElementById('editor'), {
    allowToolbar: true,
    value: '<b>This is a basic example...</b><br><br><br><br>'
});

btn.addEventListener('click', () => {
    alert(editor.getData())
})
</script>
</html>

Learn how to enable a dropping zone for images on your javascript HTML editor.

Drop any image in the rich text below.

<html>
<script src="https://jsuites.net/v6/jsuites.js"></script>
<link rel="stylesheet" href="https://jsuites.net/v6/jsuites.css" type="text/css" />

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons" />

<p class="small">Drop any image in the rich text below.</p>
<div id="root" style="width: 480px;"></div>

<script>
jSuites.editor(document.getElementById('root'), {
    parseURL: true,
    // Website parser is to read websites and images from cross domain
    remoteParser: '/docs/parser?url=',
    // Allow toolbar
    allowToolbar:true,
    height: 200,
});
</script>
</html>
<html>
<script src="https://jsuites.net/v6/jsuites.js"></script>
<link rel="stylesheet" href="https://jsuites.net/v6/jsuites.css" type="text/css" />

<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons" />

<div id="editor3"></div>
<script>
jSuites.editor(document.getElementById('editor3'), {
    allowToolbar: true,
    value: '<b>This is a basic example...</b>',
    toolbar: [{
            content: 'undo',
            onclick: function() {
                document.execCommand('undo');
            }
        },
        {
            content: 'redo',
            onclick: function() {
                document.execCommand('redo');
            }
        },
        {
            type:'divisor'
        },{
            type:'select',
            width: '160px',
            options: [ 'Verdana', 'Arial', 'Courier New' ],
            render: function(e) {
                return '<span style="font-family:' + e + '">' + e + '</span>';
            },
            onchange: function(a,b,c,d) {
                document.execCommand('fontName', false, d);
            }
        },
        {
            type: 'select',
            width: '48px',
            content: 'format_size',
            options: ['X-small','Small','Medium','Large','X-large'],
            render: function(e) {
                return '<span style="font-size:' + e + '">' + e + '</span>';
            },
            onchange: function(a,b,c,d,e) {
                document.execCommand('fontSize', false, e+1);
            }
        },
        {
            type: 'select',
            width: '50px',
            options: ['format_align_left','format_align_center','format_align_right','format_align_justify'],
            render: function(e) {
                return '<i class="material-icons">' + e + '</i>';
            },
            onchange: function(a,b,c,d) {
                if (d == 'format_align_left') {
                    document.execCommand('justifyLeft');
                } else if (d == 'format_align_center') {
                    document.execCommand('justifyCenter');
                } else if (d == 'format_align_right') {
                    document.execCommand('justifyRight');
                } else if (d == 'format_align_justify') {
                    document.execCommand('justifyFull');
                }
            }
        }
    ]
});
</script>
</html>

You can find more examples of the jSuites JavaScript HTML Editor plugin as below.