Counter

Shows word and character counts in the status bar. Updates automatically on every editor change.

Counts plain text from the document (whitespace is normalized). No toolbar button — stats appear in the status bar as soon as the plugin is loaded.

Load the bundle

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

Initialization

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

Options

This plugin has no options.

Events

counter

Fired after each recount.

app.on('counter', ({ data }) => {
    console.log(data.words, data.characters);
});

Payload:

  • words — word count.
  • characters — character count (after whitespace normalization).

API

count

Recalculates stats, updates the status bar, and emits the counter event.

app.counter.count();