Skip to content

Commit

Permalink
Merge pull request #76 from editor-js/fix/backspace-and-navigate
Browse files Browse the repository at this point in the history
Fix cursor navigation and backspace functionality CodeTool
  • Loading branch information
idebenone authored Nov 19, 2024
2 parents e34a438 + 5952ba5 commit af1cc25
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
38 changes: 38 additions & 0 deletions dev/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Code Plugin Test | EditorJS</title>
</head>
<body>
<div id="editorjs"></div>
<script src="https://cdn.jsdelivr.net/npm/@editorjs/editorjs@latest"></script>
<script src="https://cdn.jsdelivr.net/npm/@editorjs/header@latest"></script>
<script type="module">
import CodeTool from '../src/index.ts';
const editor = new EditorJS({
holder: 'editorjs',
data: {
time: 1700475383740,
blocks: [
{
id: 'aRMoZePSTD',
type: 'header',
data: { text: 'Welcome to Editor.js', level: 2 },
},
{
id: 'fcG8CCR5F8',
type: 'code',
data: { code: 'print("Namaste World")' },
},
],
},
tools: {
code: CodeTool,
header: Header,
},
});
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@editorjs/code",
"version": "2.9.2",
"version": "2.9.3",
"keywords": [
"codex editor",
"code",
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export default class CodeTool implements BlockTool {
this._data = data;

if (this.nodes.textarea) {
this.nodes.textarea.textContent = data.code;
this.nodes.textarea.value = data.code;
}
}

Expand Down Expand Up @@ -299,7 +299,7 @@ export default class CodeTool implements BlockTool {

wrapper.classList.add(this.CSS.baseClass, this.CSS.wrapper);
textarea.classList.add(this.CSS.textarea, this.CSS.input);
textarea.textContent = this.data.code;
textarea.value = this.data.code;

textarea.placeholder = this.placeholder;

Expand Down
3 changes: 3 additions & 0 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export default {
fileName: 'code',
},
},
server: {
open: './dev/index.html',
},
define: {
NODE_ENV: JSON.stringify(NODE_ENV),
VERSION: JSON.stringify(VERSION),
Expand Down

0 comments on commit af1cc25

Please sign in to comment.