-
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 for CodePair using CodeMirror 6
- Loading branch information
Showing
8 changed files
with
147 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { Button, Menu, MenuItem } from "@mui/material"; | ||
import { useState } from "react"; | ||
import { useDispatch, useSelector } from "react-redux"; | ||
import { CodeKeyType, selectEditor, setCodeKeyType } from "../../store/editorSlice"; | ||
|
||
export const BOTTOM_BAR_HEIGHT = 25; | ||
|
||
const EditorBottomBar = (props: { width: number | string }) => { | ||
const { width } = props; | ||
const dispatch = useDispatch(); | ||
const editorStore = useSelector(selectEditor); | ||
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 ( | ||
<div | ||
style={{ | ||
position: "absolute", | ||
bottom: 0, | ||
left: 0, | ||
width, | ||
background: "000000", | ||
borderTop: "1px solid #ccc", | ||
height: BOTTOM_BAR_HEIGHT, | ||
display: "flex", | ||
}} | ||
> | ||
<Button variant="text" onClick={handleOpen}> | ||
{editorStore.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> | ||
</div> | ||
); | ||
}; | ||
|
||
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