mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-23 07:36:12 +08:00
Summary: Refactor keymaps to wrap components with a <KeymapHandlers /> component. This more Reactful way of declaring keyback handlers prevents us from needing to subscribe to `atom.commands` Test Plan: new tests Reviewers: bengotow, juan Reviewed By: bengotow Differential Revision: https://phab.nylas.com/D2226
19 lines
572 B
CoffeeScript
19 lines
572 B
CoffeeScript
# Utils for testing.
|
|
CSON = require 'season'
|
|
KeymapManager = require 'atom-keymap'
|
|
|
|
NylasTestUtils =
|
|
loadKeymap: (keymapPath) ->
|
|
{resourcePath} = atom.getLoadSettings()
|
|
basePath = CSON.resolve("#{resourcePath}/keymaps/base")
|
|
atom.keymaps.loadKeymap(basePath)
|
|
|
|
if keymapPath?
|
|
keymapPath = CSON.resolve("#{resourcePath}/#{keymapPath}")
|
|
atom.keymaps.loadKeymap(keymapPath)
|
|
|
|
keyPress: (key, target) ->
|
|
event = KeymapManager.buildKeydownEvent(key, target: target)
|
|
atom.keymaps.handleKeyboardEvent(event)
|
|
|
|
module.exports = NylasTestUtils
|