Editor instance, every interaction with the editor — reading content, updating content, managing focus, listening for events, and tearing down — goes through its instance methods. All methods are synchronous unless otherwise noted, and they are available immediately after the constructor returns.
getHTML()
getText()
setHTML(html)
value option before it is inserted, so untrusted markup is safe to pass here.
Calling
setHTML() replaces the full document — it does not merge with existing content. It also pushes a new entry onto the undo stack, so users can undo the replacement.setTheme(theme)
'light' or 'dark'. The change takes effect immediately by toggling a data attribute on the editor root element.
toggleHtmlView()
view:toggle event fires after each transition.
on(event, fn)
fn to an editor event. The callback receives an event-specific payload on each fire. See the Events reference for all event names and their payloads.
off(event, fn)
on() — anonymous functions passed inline cannot be unsubscribed this way.
use(plugin)
plugins constructor option, but lets you add plugins lazily — for example, after an async feature flag check. See the Plugin API for more detail.