-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Vim binding support using CodeMirror 6 (#340)
* Add Vim binding for CodePair using CodeMirror 6 * Add vim key mapping 'jj' for insert mode * Fix argument type * Fix components to use `function` keyword * Add EditorBottomBar props interface * Fix enum members to use capital letters * Move `EditorBottomBar` into `Editor` components * Change to `Paper` component * Move codekey options to `configSlice`
- Loading branch information
Showing
12 changed files
with
210 additions
and
62 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { Button, Menu, MenuItem, Paper } from "@mui/material"; | ||
import { useState } from "react"; | ||
import { useDispatch, useSelector } from "react-redux"; | ||
import { CodeKeyType, selectConfig, setCodeKeyType } from "../../store/configSlice"; | ||
|
||
export const BOTTOM_BAR_HEIGHT = 25; | ||
|
||
interface EditorBottomBarProps { | ||
width: number | string; | ||
} | ||
|
||
function EditorBottomBar(props: EditorBottomBarProps) { | ||
const { width } = props; | ||
const dispatch = useDispatch(); | ||
const configStore = useSelector(selectConfig); | ||
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null); | ||
const open = Boolean(anchorEl); | ||
|
||
const handleOpen = (event: React.MouseEvent<HTMLButtonElement>) => { | ||
setAnchorEl(event.currentTarget); | ||
}; | ||
|
||
const handleClose = () => { | ||
setAnchorEl(null); | ||
}; | ||
|
||
const handleChangeCodeKey = (newKeyCode: CodeKeyType) => { | ||
dispatch(setCodeKeyType(newKeyCode)); | ||
handleClose(); | ||
}; | ||
|
||
return ( | ||
<Paper | ||
variant="outlined" | ||
sx={{ | ||
position: "absolute", | ||
bottom: 0, | ||
left: 0, | ||
width, | ||
borderTop: 1, | ||
borderColor: "divider", | ||
height: BOTTOM_BAR_HEIGHT, | ||
display: "flex", | ||
backgroundColor: "background.paper", | ||
}} | ||
> | ||
<Button variant="text" onClick={handleOpen}> | ||
{configStore.codeKey} | ||
</Button> | ||
<Menu | ||
id="codekey-menu" | ||
anchorEl={anchorEl} | ||
open={open} | ||
onClose={handleClose} | ||
anchorOrigin={{ | ||
vertical: "top", | ||
horizontal: "left", | ||
}} | ||
transformOrigin={{ | ||
vertical: "bottom", | ||
horizontal: "left", | ||
}} | ||
> | ||
{Object.values(CodeKeyType).map((keyType) => ( | ||
<MenuItem key={keyType} onClick={() => handleChangeCodeKey(keyType)}> | ||
{keyType} | ||
</MenuItem> | ||
))} | ||
</Menu> | ||
</Paper> | ||
); | ||
} | ||
|
||
export default EditorBottomBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.