Installation
Factory: createWordCountPlugin(onUpdate?), id word-count. Requires preset pro and enabled features.plugins. Use a constructor plugins array or usePlugin on an existing editor; do not install the same id twice. In the script build the factory belongs to the ViText namespace; workspace ESM imports are shown below.
Behavior and limitations
Adds a live word count to the status and an optional numeric callback. Paragraph and br boundaries are respected. Without this plugin the default status counts only characters.
Removal and ownership
usePlugin returns a disposer; removePlugin('word-count') removes the same plugin. Destroy automatically revokes its managed commands, subscriptions and UI. The document stays intact. Application-owned requests still need application cleanup. Plugin contract, methods.
import { ViText, createWordCountPlugin } from '@vitext-ru/editor';
const editor = new ViText('#editor', {
preset: 'pro', language: 'en',
plugins: [createWordCountPlugin()]
});
const remove = editor.usePlugin(createWordCountPlugin(words => console.log(words)));
remove();