codex-team / codex-team/editor.js

Pasting code block renders [object HTMLPreElement] instead of code content

Open
#3,010 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
TypeScript
Stars
31.9k
Forks
2.2k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

When pasting a code block into the editor, the content is inserted but rendered incorrectly as:

```text
[object HTMLPreElement]
```

instead of displaying the actual code.

## Steps to Reproduce

1. Open the editor.
2. Copy the following code:

```javascript
import EditorJS from '@editorjs/editorjs'

const editor = new EditorJS({
tools: {
// ... your tools
}
})
```

3. Paste the code into the editor.
4. Observe the rendered result.

## Actual Result

The editor displays:

```text
[object HTMLPreElement]
```

instead of the pasted code.

## Expected Result

The editor should preserve and display the pasted code content:

```javascript
import EditorJS from '@editorjs/editorjs'

const editor = new EditorJS({
tools: {
// ... your tools
}
})
```

or create a proper Code block containing the pasted content.

## Environment

- Editor.js Version: v2.31.6
- Browser: Chrome
- OS: macOS

## Screenshot :

Image

## Issue Video :

https://github.com/user-attachments/assets/1c75cac0-ce2c-43b0-a30e-bdc6471a58b2

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.