Skip to content

fix(paste): use textContent instead of innerHTML to avoid HTML tags in code - #80

Open
waterWang wants to merge 1 commit into
editor-js:masterfrom
waterWang:master
Open

fix(paste): use textContent instead of innerHTML to avoid HTML tags in code#80
waterWang wants to merge 1 commit into
editor-js:masterfrom
waterWang:master

Conversation

@waterWang

Copy link
Copy Markdown

Summary

Fixes pasting code blocks rendering as [object HTMLPreElement].

When pasting a <pre> element that contains child <code> tags (as browsers produce when copying code from pages/IDEs), element.innerHTML returns the HTML including the <code> tag, which leaks markup into the code field. element.textContent extracts only the plain text — the correct content for a code block.

Root cause reference

Test Plan

  • Pasting a <pre><code>...</code></pre> block now yields plain code text without HTML tags
  • Existing behavior preserved for plain <pre> content

…n code

When pasting a <pre> element containing <code> child tags,
element.innerHTML returns the HTML including the <code> tag.
Using textContent extracts only the plain text, which is the
correct behavior for code blocks.

Ref: codex-team/editor.js#3010
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant