How it works
Three ideas carry the rest. Values travel one path each way, edits leave through one gate, and the layers stack bottom-up.
Values travel one path each way
Going in and coming out, both pass through the same filter.
Four properties fall out of that one picture.
getHtml()never hands back the incidental markup a browser leaves behind while editing. It re-filters the current DOM every time.- The filter is idempotent. Feeding an
onChangevalue straight back intosetHtml()does nothing at all. - The round trip is lossless. What gets put on for the way out comes off on the way in.
- Values are always compared soul against soul. Comparing an output string with the document itself always differs, and the caret jumps.
Why the same document goes by four names, and what each one means, is in the Glossary.
Rendering HTML you stored
The safety of getHtml() is about the string you just made. When you render HTML that went to a database and came back, you still need sanitizing on your side.
Edits leave through one gate
Every path that changes the document goes through the same gate: toolbar buttons, input rules, paste, setHtml(), and undo alike.
So an edit that skips the gate cannot be undone and never reaches the host. That is why a wing that touched the document directly must call context.commit().
The layers stack bottom-up
editorthe facade and its controllers — they know one shared surface, never each otheruifloating boxes — placement, stacking order, the UI wings are handedwingsthe wings that ship in the box — they use only the contract and the flowerinputbrowser events become commands — typing, paste, files, input rulesflowerwhere wings get their nectar — the one door into core functionalitycommandspure editing functions — they change the document and answer whether they didcorepure document logic — DOM, selection, normalizing, filtering, historycontractthe wing contract — schema, context, handle, registry, locale, iconsThe layer worth pausing on is flower. It is the only door through which a wing reaches core functionality, and the wings that ship in the box use the same door as anyone else's. There is no shortcut reserved for the built-ins.
New features are wings. If it feels like a core file has to change, that is usually a sign that the contract is missing something.
Next
- Glossary — the words this documentation uses
- Build your own wing — build a format that does not exist yet