Slash Commands

Type /on an empty line to open an inline picker. 15 built-in blocks (headings, lists, tables, quotes, code, dividers, today’s date) plus every registered AI action. Keyboard-driven — move with ↑ ↓, insert with Enter, dismiss with Esc. Filter by typing a few characters.

Try it: place the cursor on a new line and type / to see the menu.

Suggested: /h1, /table, /ai, /quote.

Example code

<link rel="stylesheet" href="/richtexteditor/rte_theme_default.css" />
<script type="text/javascript" src="/richtexteditor/rte.js"></script>
<script type="text/javascript" src='/richtexteditor/plugins/all_plugins.js'></script>

<div id="slashcmd_editor">
    <p>Try it: place the cursor on a new line and type <strong>/</strong> to see the menu.</p>
    <p>Suggested: <code>/h1</code>, <code>/table</code>, <code>/ai</code>, <code>/quote</code>.</p>
</div>

<script>
    var slashcfg = {
        slashCommandEnabled: true,
        slashCommandIncludeAi: true,
        toolbar: "default"
    };
    var slashEditor = new RichTextEditor("#slashcmd_editor", slashcfg);

    // Register a custom slash command in addition to the built-ins.
    if (slashEditor.slashCommands) {
        slashEditor.slashCommands.register({
            id: "signature",
            label: "My signature",
            keywords: ["sig", "sign"],
            run: function () {
                slashEditor.insertHTML("<p>&mdash; Best regards,<br/>Your name</p>");
            }
        });
    }
</script>