Skip to content

Headless Lexical doesn't works #7339

@fabioquarantini

Description

@fabioquarantini

Link to reproduction

No response

Payload Version

3.0.0-beta

Node Version

20

Next.js Version

14.3.0-canary.68

Describe the Bug

I'm working on a import script to convert HTML to Lexical.
To do it, I'm trying to use it the headless editor as mentioned in the documentation. ( https://payloadcms.com/docs/beta/lexical/converters#headless-editor )
When it executed, in the terminal appear the following error:

node:internal/process/esm_loader:34
      internalBinding('errors').triggerUncaughtException(
                                ^
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".css" for /node_modules/react-image-crop/dist/ReactCrop.css
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:160:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:203:36)
    at defaultLoad (node:internal/modules/esm/load:143:22)
    at async nextLoad (node:internal/modules/esm/hooks:866:22)
    at async load (file:///node_modules/tsx/dist/esm/index.mjs?1721835165950:2:1762)
    at async nextLoad (node:internal/modules/esm/hooks:866:22)
    at async Hooks.load (node:internal/modules/esm/hooks:449:20)
    at async handleMessage (node:internal/modules/esm/worker:196:18) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

Node.js v20.12.2

Reproduction Steps

The script is the following:

import { importConfig } from 'payload/node'
import { createHeadlessEditor } from '@lexical/headless'
import { getEnabledNodes, sanitizeServerEditorConfig } from '@payloadcms/richtext-lexical'

async function run() {

  const payloadConfig = await importConfig('../../../../payload.config.ts')
  const yourEditorConfig = {
    features: [],
  }
  const editorConfig = await sanitizeServerEditorConfig(yourEditorConfig, payloadConfig);

  const headlessEditor = createHeadlessEditor({
    nodes: getEnabledNodes({
      editorConfig
    }),
  })

  process.exit(0)
}

run().catch(console.error)

Run it with package.json script:

"standalone-script": "tsx ./src/app/\\(payload\\)/_scripts/standalone-script.ts",

Adapters and Plugins

No response

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions