Installation
Factory: createDirtyStatePlugin(onUpdate), id dirty-state. 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
Reports changes to the application relative to the initial document. It does not write or mark an external database as saved. Treat it as a notification signal and implement your own persistence workflow.
Removal and ownership
usePlugin returns a disposer; removePlugin('dirty-state') 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, createDirtyStatePlugin } from '@vitext-ru/editor';
const editor = new ViText('#editor', {
preset: 'pro', language: 'en',
plugins: [createDirtyStatePlugin(dirty => console.log(dirty))]
});
const remove = editor.usePlugin(createDirtyStatePlugin(dirty => console.log(dirty)));
remove();