From a60e06c84262514aab88138184f92c7694bc44fd Mon Sep 17 00:00:00 2001 From: water <672684719@qq.com> Date: Tue, 11 Aug 2026 19:40:01 +0800 Subject: [PATCH] fix(paste): use textContent instead of innerHTML to avoid HTML tags in code When pasting a
element containing child tags,
element.innerHTML returns the HTML including the tag.
Using textContent extracts only the plain text, which is the
correct behavior for code blocks.
Ref: codex-team/editor.js#3010
---
src/index.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/index.ts b/src/index.ts
index 0f3fe5f..7345cc2 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -330,7 +330,7 @@ export default class CodeTool implements BlockTool {
*/
private handleHTMLPaste(element: HTMLElement): void {
this.data = {
- code: element.innerHTML,
+ code: element.textContent,
};
}
}