react-codemirror2 icon indicating copy to clipboard operation
react-codemirror2 copied to clipboard

Fix kb types

Open andyrichardson opened this issue 5 years ago • 6 comments

Fix #144

Events have been determined by referring to the MDN docs.

andyrichardson avatar Jun 24 '19 13:06 andyrichardson

Coverage Status

Coverage remained the same at 81.174% when pulling 009154b675a6cc78e8fd51237e2a25ef7fb40746 on andyrichardson:fix-kb-types into a633e7dd673ddf5bdb07e2ed664a03aa47159bfa on scniro:master.

coveralls avatar Jun 24 '19 13:06 coveralls

Hey! Not related to the repo but i'm using plain CodeMirror inside a TS/React project and i'm trying to attach a function to the on('keydown') method:

codeMirror.on("keydown", handleKeyDown);

But i'm getting this:

Type 'Event' is missing the following properties from type 'KeyboardEvent': altKey, char, charCode, code, and 16 more.

I used the same interface as you in my handler:

const handleKeyDown: DomEvent<KeyboardEvent> = (instance, event) => {...}

Def:

interface DomEvent<T extends Event = Event> {
  (editor: CodeMirror.Editor, event: T): void;
}

This PR was enough for you to fix it? Some ideas on why it's not working for me are going to be highly appreciated 🙏

zant avatar Sep 10 '19 17:09 zant

@gonzarodriguezt this was the same issue I had. This PR fixes it.

andyrichardson avatar Sep 24 '19 15:09 andyrichardson

@andyrichardson @grdnrt I am a lot shorter on time these days as when I started this project. Codemirror & React APIs are moving to quickly for me to keep atop of for the day-to-day. I am looking for a co-maintainer of this project. Please contact me directly if you are interested. Thank you for understanding.

scniro avatar Jan 19 '20 17:01 scniro

@andyrichardson do you mind doing a pull from master to resolve conflicts? Then I'll merge this!

elsigh avatar May 19 '20 14:05 elsigh

For sure, I'll take a quick look some time today

andyrichardson avatar May 20 '20 09:05 andyrichardson