Icons

Enables the insertion of SVG icons into content, enhancing visual appeal with scalable graphics.

Click on the star icon in the toolbar, then choose an icon from the popup to insert it.

Code

<!DOCTYPE html>
<html>
    <head>
        <title>Redactor</title>
        <meta charset="utf-8">

        <!-- css -->
        <link rel="stylesheet" href="/your-folder/redactor.css" />
    </head>
    <body>
        <!-- element -->
        <textarea id="entry">...</textarea>

        <!-- js -->
        <script src="/your-folder/redactor.js"></script>
        <script src="/your-folder/plugins/icons/icons.js"></script>

        <!-- call -->
        <script>
        Redactor('#entry', {
            plugins: ['icons']
        });
        </script>
    </body>
</html>

Usage

The set of icons that will be shown in the popup of the plugin is specified as an array in the setting of the plugin itself. This set can be changed by specifying your own array like this:


Redactor('#entry', {
    plugins: ['icons'],
    icons: {
        items: [
            '<svg..>',
            '<svg..>',
            '<svg..>'
        ]
    }
});

Icons can be specified as SVG and HTML, for example, here's how to specify the FontAwesome icons:


Redactor('#entry', {
    plugins: ['icons'],
    icons: {
        items: [
            '<i class="fas fa-address-book"></i>',
            '<i class="fas fa-address-card"></i>',
            '<i class="fas fa-archway"></i>'
        ]
    }
});

Of course, you can mix SVG and HTML icons in one set:


Redactor('#entry', {
    plugins: ['icons'],
    icons: {
        items: [
            '<svg..>',
            '<svg..>',
            '<i class="fas fa-address-card"></i>',
            '<i class="fas fa-archway"></i>'
        ]
    }
});

By default, the plugin adds its button to the toolbar and context bar. To remove it from the context bar, disable the context setting:


Redactor('#entry', {
    plugins: ['icons'],
    icons: {
        context: false
    }
});