Registry / database / draftjs-to-lexical

draftjs-to-lexical

JSON →
library0.0.5jsnpmunverified

A utility library for migrating content from Draft.js to Lexical editor format. Current version 0.0.5 is pre-release beta, with no established release cadence. It converts Draft.js contentState to Lexical serialized format, covering common block and inline styles. Key differentiators: handles Draft.js entities (links, mentions) and nested lists. Suitable for migrating legacy Draft.js editors to Lexical. Due to early stage, expect API changes and limited documentation.

npm install draftjs-to-lexical
INSTALL
IMPORT
SIG · DRAFTJS-TO-LEXICAL
D
draftjs-to-lexical
databasejavascriptv0.0.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

draftjsToLexical
import { draftjsToLexical } from 'draftjs-to-lexical'
const draftjsToLexical = require('draftjs-to-lexical')
ESM-only package; no CJS support.
convertFromDraft
import { convertFromDraft } from 'draftjs-to-lexical'
import convertFromDraft from 'draftjs-to-lexical'
Named export, not default export.
types
import type { DraftLexicalConversionResult } from 'draftjs-to-lexical'
import { DraftLexicalConversionResult } from 'draftjs-to-lexical'
Use type import for TypeScript types to avoid runtime import.

Converts a Draft.js contentState object to a Lexical editor state (array of nodes).

import { draftjsToLexical } from 'draftjs-to-lexical'; // Example Draft.js contentState const contentState = { blocks: [ { key: 'item1', type: 'header-one', text: 'Hello World', depth: 0, inlineStyleRanges: [], entityRanges: [], data: {} } ], entityMap: {} }; const lexicalState = draftjsToLexical(contentState); console.log(JSON.stringify(lexicalState, null, 2)); // Output: Lexical nodes array // [ // { // "children": [ { "detail": 0, "format": 0, "mode": "normal", "style": "", "text": "Hello World", "type": "text", "version": 1 } ], // "direction": null, // "format": "", // "indent": 0, // "type": "heading", // "version": 1, // "tag": "h1" // } // ]
Debug
Known issues
breakingPackage is unstable; API may change without notice.
fix
Pin exact version in package.json.
affects: >=0.0.1
gotchaDoes not support all Draft.js block types (e.g., atomic, blockquote, code-block).
fix
Check source for supported types; fallback to manual conversion.
affects: >=0.0.1
gotchaEntity handling is limited to links and mentions; custom entities may be lost.
fix
Pre-process contentState to map custom entities.
affects: >=0.0.1
gotchaNo official documentation or README; rely on source code.
fix
Examine node_modules/draftjs-to-lexical/dist for types and implementation.
affects: >=0.0.1
gotchaInline styles (bold, italic) are mapped but custom styles are not.
fix
Apply custom styles post-conversion.
affects: >=0.0.1
Errors
Common errors & fixes
Cannot find module 'draftjs-to-lexical' or its corresponding type declarations.
Package not installed or tsconfig missing typeRoots.
fix
Run `npm install draftjs-to-lexical` and ensure `node_modules` is included in tsconfig.
Uncaught TypeError: draftjsToLexical is not a function
Incorrect import (default instead of named).
fix
Use `import { draftjsToLexical } from 'draftjs-to-lexical'`.
Error: draftjsToLexical expects an object with blocks and entityMap properties.
Passed wrong argument (e.g., raw Text instead of Draft.js contentState).
fix
Pass a valid Draft.js contentState object: `{ blocks: [...], entityMap: {} }`.
Type 'undefined' is not assignable to type 'DraftJsContentState'.
ContentState object may be undefined in some scenarios.
fix
Check that contentState is defined before calling draftjsToLexical.
Upgrade
Version history
0.0.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
draftjs-to-lexical — npm install draftjs-to-lexical · libregistry