Merge Tag

Adds toolbar and addbar buttons for inserting merge tag blocks — non-editable placeholders for mail-merge style content (for example Name, Email).

Click Merge Tag in the toolbar or addbar and pick a tag. If the caret is already on a merge tag block, the selection updates that block instead.

Load the bundle

<script src="/assets/redactor/redactor.js"></script>
<script src="/assets/redactor/plugins/mergetag/mergetag.js"></script>

Initialization

const app = Redactor('#entry', {
    plugins: ['mergetag']
});

Options

  • items (string[])
    • default ['Name', 'Lastname', 'Email']
    • Tag labels shown in the dropdown.
  • icon (string)
    • SVG icon HTML for the toolbar and addbar buttons.
Redactor('#entry', {
    plugins: ['mergetag'],
    mergetag: {
        items: ['First name', 'Last name', 'Email', 'Company']
    }
});

Language strings

en: {
    mergetag: {
        title: 'Merge Tag'
    }
}

Events

This plugin does not emit events.

API

add

Inserts a new merge tag block, or updates the current merge tag if the caret is on one.

Parameters:

  • content (string) — tag label.
app.mergetag.add({ content: 'Email' });

set

Updates the content of the current merge tag block.

Parameters:

  • content (string) — new tag label.
app.mergetag.set({ content: 'Company' });

remove

Removes the current merge tag block.

app.mergetag.remove();