codex-team / codex-team/editor.js

Multiple EditorJS instances on the same page cause inline shortcut registration to fail

Open
#3,002 0 comments 1 reaction 2 assignees Claimed by @neSpecc View on GitHub
bug
Dominant language
TypeScript
Stars
31.9k
Forks
2.2k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

When multiple EditorJS instances are initialized on the same page, the second instance fails to register its inline tool shortcuts, causing an error thrown by `Shortcuts.add()`.

This was introduced by the change from `this.Editor.UI.nodes.redactor` to `document` as the `on` target in `inline.ts > enableShortcuts()`. https://github.com/codex-team/editor.js/pull/2891/changes#diff-e55ad4bb9846bb8d75e77413ab3e49c30e75f6bb8b58833d2b539cebb8186b10

1. Create two or more EditorJS instances on the same page with inline tools that have shortcuts (e.g. `bold`, `italic`, `inlineCode`)
2. Initialize the second instance
3. Observe the error

Expected behavior: Multiple EditorJS instances should be able to coexist on the same page without conflicting on inline shortcut registration.

Suggested Fix: One possible approach would be to conditionally bind shortcuts depending on the read-only mode.

Screenshots:

Image

Device, Browser, OS: Chromium 147.0.7727.116

Editor.js version: 2.31.6

Plugins you use with their versions: N/A

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.