🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

@slate-serializers/dom

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@slate-serializers/dom

Serialize Slate JSON objects to the DOM. Can be used with `htmlparser2` and associated utilities to modify the DOM and generate HTML. Used by other serializers in this monorepo.

latest
Source
npmnpm
Version
2.5.3
Version published
Weekly downloads
30K
1.94%
Maintainers
1
Weekly downloads
 
Created
Source

@slate-serializers/dom

Convert Slate JSON to a domhandler document tree (the same DOM model used by htmlparser2 / html-entities).

It is used by @slate-serializers/html (slateToHtml) before serializing to an HTML string. Use slateToDom directly when you want to inspect or manipulate the tree (e.g. with domutils) before calling dom-serializer yourself.

Live examples: slateToDom on the demo site.

Install

npm install @slate-serializers/dom

Usage

import { slateToDomConfig, slateToDom } from '@slate-serializers/dom'

const slate = [
  {
    type: 'h1',
    children: [{ text: 'Heading 1' }],
  },
]

const dom = slateToDom(slate, slateToDomConfig)

Configuration

  • SlateToDomConfig — markMap, elementMap, elementTransforms, markTransforms, elementAttributeTransform, and formatting options. See slateToDom configuration in the repo and the interactive docs.

DOM helpers from this package

Element and Text are re-exported from domhandler so you can use new Element(...) without adding domhandler only for the constructor:

import { Element, type SlateToDomConfig } from '@slate-serializers/dom'

ChildNode is available as import type { ChildNode } only.

Engineering

See Engineering decisions.

Keywords

slate

FAQs

Package last updated on 20 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts