1
1
import { PlusOutlined , QuestionCircleOutlined } from "@ant-design/icons" ;
2
2
import { Button , Tour , TourProps , message , notification } from "antd" ;
3
- import { useRef , useState } from "react" ;
3
+ import { useContext , useEffect , useRef , useState } from "react" ;
4
4
import { useSelector } from "react-redux" ;
5
5
import { FlexRow } from "../../common" ;
6
6
7
7
import { styled } from "styled-components" ;
8
+ import { AppContext } from "../../App" ;
8
9
import Tooltip from "../../common/tooltip" ;
9
10
import {
10
11
setNeuron ,
@@ -31,15 +32,25 @@ const Ilearn = () => {
31
32
const refCategoryFilter = useRef < any > ( null ) ;
32
33
const refStudyButton = useRef < any > ( null ) ;
33
34
const refIntervals = useRef < any > ( null ) ;
35
+
34
36
const [ open , setOpen ] = useState < boolean > ( false ) ;
37
+ const [ hasChanged , setHasChanged ] = useState < boolean > ( false ) ;
38
+ const [ studyList , setStudyList ] = useState < Neuron [ ] > ( [ ] ) ;
39
+ const [ repititionDay , setRepititionDay ] = useState < number > ( ) ;
40
+ const [ showEditModal , setShowEditModal ] = useState < boolean > ( false ) ;
41
+ const [ showStudyModal , setShowStudyModal ] = useState < boolean > ( false ) ;
35
42
36
- const [ hasChanged , setHasChanged ] = useState ( false ) ;
37
43
const { selectedNode, selected } = useSelector ( ( v : RootState ) => v . neuron ) ;
44
+ const { keyEvent } = useContext ( AppContext ) ! ;
38
45
const dispatch = useAppDispatch ( ) ;
39
- const [ studyList , setStudyList ] = useState < Neuron [ ] > ( [ ] ) ;
40
- const [ repititionDay , setRepititionDay ] = useState < number > ( ) ;
41
- const [ showEditModal , setShowEditModal ] = useState ( false ) ;
42
- const [ showStudyModal , setShowStudyModal ] = useState ( false ) ;
46
+
47
+ useEffect ( ( ) => {
48
+ // Ctrl+C opens a modal to add new
49
+ if ( keyEvent ?. key === "c" && keyEvent . ctrlKey && ! showEditModal && ! showStudyModal ) {
50
+ keyEvent . preventDefault ( ) ;
51
+ setShowEditModal ( true ) ;
52
+ }
53
+ } , [ keyEvent ] ) ;
43
54
44
55
const steps : TourProps [ "steps" ] = [
45
56
{
0 commit comments