Commit bd5c631
fix: allow multiple editor instances to register inline shortcuts on document
Two bugs caused inline shortcuts to fail when multiple EditorJS instances
were on the same page:
1. Mismatch: shortcuts were registered on `document` but removed from
`this.Editor.UI.nodes.redactor`, so they were never actually removed.
2. Because shortcuts accumulated on `document` forever, the second editor's
attempt to register the same shortcuts threw an error (silently caught),
meaning the second editor's inline shortcuts were never registered at all.
Fixes:
- Remove the throw in `Shortcuts.add()` to allow multiple editors to each
register their own handler for the same shortcut on `document`. Each
handler already guards via `if (!currentBlock) return`, so only the
focused editor responds.
- Fix `close()` to call `Shortcuts.remove(document, shortcut)` matching
where they were registered.
- Update type signatures from `Element` to `HTMLElement | Document` to
match actual usage.
Agent-Logs-Url: https://github.com/codex-team/editor.js/sessions/6c11dfbe-e93a-4fd6-a88e-ef0409aa3d73
Co-authored-by: neSpecc <3684889+neSpecc@users.noreply.github.com>1 parent 10b7045 commit bd5c631
2 files changed
Lines changed: 5 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | 54 | | |
63 | 55 | | |
64 | 56 | | |
| |||
75 | 67 | | |
76 | 68 | | |
77 | 69 | | |
78 | | - | |
| 70 | + | |
79 | 71 | | |
80 | 72 | | |
81 | 73 | | |
| |||
104 | 96 | | |
105 | 97 | | |
106 | 98 | | |
107 | | - | |
| 99 | + | |
108 | 100 | | |
109 | 101 | | |
110 | 102 | | |
| |||
0 commit comments