Events

Payloads, applied revisions and subscription cleanup.

1.0.0-beta.6 · Local build · desktop

Event contract

EventPayloadTrigger
changehtml, json, css, revisionApplied document/styles change, including undo
selectionChangefrom, to, text, revisionSelection change
warningImportReport plus source: paste/drop/importImport requiring review
errorErrorProcessing failure

Constructor onChange handles change. on(name, listener) returns unsubscribe; off requires the same event name and function. Independent event ordering is not a server transaction protocol.

Source drafts

HTML/Markdown emit change after successful validation. Invalid drafts do not become the canonical document. Events do not write to a server; queues, retries and authentication belong to your application.

Revision and cleanup

Capture revision with a range for asynchronous work. Selection changes and document mutations are different. Release application-owned resources before destroy; ViText clears its own managed listeners. Storage, document.

const off = editor.on('change', ({ html, css, json, revision }) => {
  console.log({ html, css, json, revision });
});
editor.on('warning', report => console.log(report.warnings));
off();

Search documentation

No results. Try different words.

All documentation