Mounting and lifecycle
createClassicEditor(host, options) accepts a textarea or HTMLElement and returns a Promise. Await creation before using the handle. A textarea integrates with native forms; an element host needs application-owned persistence.
Do not mount twice on the same host. Await destroy() before removing a dynamic field or modal. Use setData() for stored HTML and getData() for canonical content, rather than reading the authoring DOM.
Checked code
ts
export async function withHost(host: HTMLElement) {
const editor = await createClassicEditor(host, { data: '<p>Hello</p>' });
editor.setData('<p>Updated</p>');
const html = editor.getData();
editor.setReadonly(true);
await editor.destroy(); // Before removing the host element.
return html;
}Checked against the published types; see imports and types for imports.