Installation
Factory: createCharacterLimitPlugin({ limit: 5000 }), id character-limit. 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
The positive safe-integer limit defaults to 5000. Remaining/exceeded characters appear in status; warnings do not block typing or paste. The count is getText().trim().length: UTF-16 units including block boundaries, without HTML/CSS. Undo/import update it. Enforce hard limits in the application/server.
Removal and ownership
usePlugin returns a disposer; removePlugin('character-limit') 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, createCharacterLimitPlugin } from '@vitext-ru/editor';
const editor = new ViText('#editor', {
preset: 'pro', language: 'en',
plugins: [createCharacterLimitPlugin({ limit: 5000 })]
});
const remove = editor.usePlugin(createCharacterLimitPlugin({ limit: 300 }));
remove();