Skip to content

Commit c0da232

Browse files
committed
fix(paste): replace PasteEvent with HTMLPasteEvent to preserve innerHTML
1 parent 82402cb commit c0da232

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@editorjs/code",
3-
"version": "2.9.3",
3+
"version": "2.9.4",
44
"keywords": [
55
"codex editor",
66
"code",

src/index.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import './index.css';
22
import { getLineStartPosition } from './utils/string';
33
import { IconBrackets } from '@codexteam/icons';
4-
import type { API, BlockTool, BlockToolConstructorOptions, BlockToolData, PasteConfig, PasteEvent, SanitizerConfig, ToolboxConfig } from '@editorjs/editorjs';
4+
import type { API, BlockTool, BlockToolConstructorOptions, BlockToolData, HTMLPasteEvent, PasteConfig, SanitizerConfig, ToolboxConfig } from '@editorjs/editorjs';
55

66
/**
77
* CodeTool for Editor.js
@@ -160,16 +160,10 @@ export default class CodeTool implements BlockTool {
160160
* onPaste callback fired from Editor`s core
161161
* @param event - event with pasted content
162162
*/
163-
public onPaste(event: PasteEvent): void {
164-
const detail = event.detail;
165-
166-
if ('data' in detail) {
167-
const content = detail.data as string;
168-
169-
this.data = {
170-
code: content || '',
171-
};
172-
}
163+
public onPaste(event: HTMLPasteEvent): void {
164+
this.data = {
165+
code: event.detail.data.innerHTML,
166+
};
173167
}
174168

175169
/**

0 commit comments

Comments
 (0)