MCPcopy
hub / github.com/codex-team/editor.js / add

Method add

src/components/utils/shortcuts.ts:53–70  ·  view source on GitHub ↗

* Register shortcut * * @param shortcut - shortcut options

(shortcut: ShortcutData)

Source from the content-addressed store, hash-verified

51 * @param shortcut - shortcut options
52 */
53 public add(shortcut: ShortcutData): void {
54 const foundShortcut = this.findShortcut(shortcut.on, shortcut.name);
55
56 if (foundShortcut) {
57 throw Error(
58 `Shortcut ${shortcut.name} is already registered for ${shortcut.on}. Please remove it before add a new handler.`
59 );
60 }
61
62 const newShortcut = new Shortcut({
63 name: shortcut.name,
64 on: shortcut.on,
65 callback: shortcut.handler,
66 });
67 const shortcuts = this.registeredShortcuts.get(shortcut.on) || [];
68
69 this.registeredShortcuts.set(shortcut.on, [...shortcuts, newShortcut]);
70 }
71
72 /**
73 * Remove shortcut

Callers 15

renderMethod · 0.45
renderMethod · 0.45
renderMethod · 0.45
renderMethod · 0.45
commands.tsFile · 0.45
setCursorMethod · 0.45
makeMethod · 0.45
prepareMethod · 0.45
createShadowMethod · 0.45
makeMethod · 0.45
blockActionsMethod · 0.45

Calls 3

findShortcutMethod · 0.95
getMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected