Text and lists
Select text for inline formatting such as bold, italic and links. Paragraphs, headings, quotes and lists operate on blocks. Alignment and indentation use commands and participate in undo history.
code is inline semantics; pre preserves whitespace and line breaks. Avoid using headings only for appearance or repeated spaces for indentation.
Existing classes, attributes and CMS markers should survive editing. Check the HTML against your host stylesheet after changing block types.
Minimal content and expected behavior
export async function editArticle(host: HTMLElement) {
return createClassicEditor(host, {
data: '<h2>Article</h2><p class="intro">Select text to format it.</p><ul><li>First item</li></ul>',
});
}Select text to toggle bold, or place the caret in a list item to change its list style. Undo restores the previous state; read getData() to inspect the HTML.
Common errors
Commands enable or disable according to selection. External buttons should restore editor focus before executing public commands. Do not reconstruct persisted content from the DOM.