Mention

Just start to type '@jo' somewhere in the text.

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/mention/mention.js"></script>

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

Usage

The mention script receives a POST variable mention and must return JSON data such as:


{
    "alex": {
        "item": "Alex", // any text or HTML that will be displayed as a list item in the inline dropdown
        "replacement": "<a href="/users/alex/">@alex</a>" // any HTML that will replace the trigger text
    },
    "john": {
        "item": "John",
        "replacement": "<a href="/users/john/">@john</a>"
    }
}

If there are no results, the mention script should return an empty response.

Mention plugin has additional optional settings:


mention: {
    url: '/your-folder/mention-script/',
    start: 2, // start point (1 - by default)
    trigger: '#' // start trigger (@ - by default)
}