slateToDom
From @slate-serializers/dom. Converts Slate JSON to a htmlparser2 DOM (nodes use the same model as domhandler). slateToHtml uses this pipeline and then serializes to an HTML string—you only need slateToDom when you want to walk or mutate the DOM before serialization.
- Implementation: packages/dom/src/lib/serializers.ts
- Default config (shared shape with
slateToHtml): packages/dom/src/lib/config/default.ts - Core conversion: packages/dom/src/lib/utilities/convert-slate.ts (
convertSlateis also exported for advanced use).
Usage
Additional exports
The package also exports helpers such as extractCssFromStyle, styleMapToAttribs, and isEmptyObject for working with attributes and styles. It re-exports the ChildNode type and the Element and Text constructors from domhandler so you can import them from @slate-serializers/dom or @slate-serializers/html without a direct domhandler dependency — see PR #215 and PR #218. Index: packages/dom/src/index.ts.
@slate-serializers/utilities
A separate package with small shared helpers (nested property access, style object handling, etc.). Most apps consume serializers through @slate-serializers/html or dom without importing utilities directly; reach for it when you extend or debug serializers.
Source: packages/utilities/src/index.ts.
Further reading
- Engineering decisions — Slate compatibility,
htmlparser2, whitespace. - slateToHtml configuration —
markMap,elementTransforms, and encoding options apply to the same DOM config type.