codex-team / editor.js

A block-style editor with clean JSON output
https://editorjs.io
Apache License 2.0
28.4k stars 2.07k forks source link

Uncaught TypeError: Cannot read properties of undefined (reading 'onFocus') #2399

Open cptiwari20 opened 1 year ago

cptiwari20 commented 1 year ago

Describe a bug. Uncaught TypeError: Cannot read properties of undefined (reading 'onFocus'), shows up when I hit tab button on the editor js or some other keys while selecting the items

Expected behavior: It should focus on the selected content or block, It does sometimes but not. How can I handle such unexpected errors?

Error Message:

Uncaught TypeError: Cannot read properties of undefined (reading 'onFocus')
    at onFlip (editorjs.mjs:3729:1)
    at editorjs.mjs:3592:1
    at Array.forEach (<anonymous>)
    at G.flipCallback (editorjs.mjs:3592:1)
    at G.flipRight (editorjs.mjs:3523:1)
    at G.onKeyDown (editorjs.mjs:3462:1)

image

Device, Browser, OS: Windows/MacOs

Editor.js version: 2.26.2

Plugins you use with their versions: "@editorjs/checklist": "^1.4.0", "@editorjs/delimiter": "^1.3.0", "@editorjs/editorjs": "^2.26.2", "@editorjs/embed": "^2.5.3", "@editorjs/header": "^2.7.0", "@editorjs/image": "^2.8.1", "@editorjs/inline-code": "^1.4.0", "@editorjs/link": "^2.5.0", "@editorjs/marker": "^1.3.0", "@editorjs/nested-list": "^1.3.0", "@editorjs/paragraph": "^2.9.0", "@editorjs/quote": "^2.5.0", "@editorjs/raw": "^2.4.0", "@editorjs/table": "^2.1.2", "@editorjs/warning": "^1.3.0",

neSpecc commented 1 year ago

Can't reproduce. Please, use the latest editor.js version and provide a demo where we can reproduce the problem

ShebangDog commented 7 months ago

same

In my case, I opened Blocktune and moved the cursor on it. Then, the application displayed an error.

ShebangDog commented 7 months ago

Sorry, I resolved it. I forgot to use renderSettings instead of settings.

So i use renderSettings for rendering settings, then it resolved

before

class Paragraph extends ParagraphToolEditor {
...
constructor() {
  this.settings = [ /* setting-styles */ ]
}
}

after

class Paragraph extends ParagraphToolEditor {
...
  renderSettings() {
    return [ /* settings-styles */ ]
  } 
}

refs: https://editorjs.io/tools-api/#rendersettings