-
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.
* fix(yorkie_intelligence): integrate YorkieIntelligence into FormatBar * refactor(formatBar) : change naming formatBar -> toolBar * chore(index.tsx): remove unused code * chore(ToolBar): rename FormatBar to ToolBar - change Box to Divider - set up flex using stack component - remove TooltipToggleButton style margin and minWidth * chore(YorkieIntelligence): change setting activated - remove style pointerEvents and, use disabled attribute - remove true check (activated) * chore(Editor): remove true check edtiorStore.cmView * chore(YorkieIntelligence): remove variable activated - change type assertion(intelligenceFooterPivot) to if conditional statement * refactor(YorkieIntelligence): add set up debousing for showToolBar - change naming showFormatBar -> showToolBar - add set up Transition (Effect: Fade, delay: 300ms) * refactor(YorkieIntelligence): remove unnecessary selectionchange event listener * chore(Editor): adjust position of toolbar in Editor.tsx * fix(YorkieIntelligence): improve intelligence footer pivot handling - improve intelligence footer pivot error when changing selection after text formatting * �Change `TODO` comment --------- Co-authored-by: devleejb <[email protected]>
- Loading branch information
Showing
7 changed files
with
149 additions
and
148 deletions.
There are no files selected for viewing
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import { Popover, ToggleButtonGroup, Divider, Stack, Fade } from "@mui/material"; | ||
import TooltipToggleButton from "../common/TooltipToggleButton"; | ||
import { ToolBarState, useFormatUtils, FormatType } from "../../hooks/useFormatUtils"; | ||
import YorkieIntelligence from "./YorkieIntelligence"; | ||
import { useDebounce } from "react-use"; | ||
import { useState } from "react"; | ||
|
||
interface ToolBarProps { | ||
toolBarState: ToolBarState; | ||
onChangeToolBarState: React.Dispatch<React.SetStateAction<ToolBarState>>; | ||
} | ||
|
||
function ToolBar({ | ||
toolBarState: { show: showToolBar, position: formatBarPosition, selectedFormats }, | ||
onChangeToolBarState, | ||
}: ToolBarProps) { | ||
const { toggleButtonChangeHandler } = useFormatUtils(); | ||
const [debouncedShowToolBar, setDebouncedShowToolBar] = useState<boolean | null>(null); | ||
|
||
useDebounce( | ||
() => { | ||
setDebouncedShowToolBar(showToolBar); | ||
}, | ||
500, | ||
[showToolBar] | ||
); | ||
|
||
if (!debouncedShowToolBar) return; | ||
|
||
return ( | ||
<Popover | ||
open={debouncedShowToolBar} | ||
anchorReference="anchorPosition" | ||
anchorPosition={{ | ||
top: formatBarPosition.top, | ||
left: formatBarPosition.left, | ||
}} | ||
onClose={() => onChangeToolBarState((prev) => ({ ...prev, show: false }))} | ||
anchorOrigin={{ | ||
vertical: "top", | ||
horizontal: "left", | ||
}} | ||
transformOrigin={{ | ||
vertical: "bottom", | ||
horizontal: "left", | ||
}} | ||
disableAutoFocus | ||
TransitionComponent={Fade} | ||
TransitionProps={{ timeout: 300 }} | ||
> | ||
<Stack direction={"row"} margin={"5px 7px"}> | ||
<YorkieIntelligence /> | ||
<Divider | ||
orientation="vertical" | ||
flexItem | ||
sx={{ height: "20px", alignSelf: "center", margin: "0 5px" }} | ||
/> | ||
<ToggleButtonGroup | ||
value={Array.from(selectedFormats)} | ||
onChange={toggleButtonChangeHandler(selectedFormats, onChangeToolBarState)} | ||
exclusive | ||
aria-label="text formatting" | ||
> | ||
<Stack direction={"row"} gap={"5px"} alignItems={"center"}> | ||
<TooltipToggleButton | ||
color={selectedFormats.has(FormatType.ITALIC) ? "primary" : "secondary"} | ||
title={"Cmd+I / Ctrl+I"} | ||
value={FormatType.ITALIC} | ||
> | ||
<i>i</i> | ||
</TooltipToggleButton> | ||
<TooltipToggleButton | ||
color={selectedFormats.has(FormatType.BOLD) ? "primary" : "secondary"} | ||
title={"Cmd+B / Ctrl+B"} | ||
value={FormatType.BOLD} | ||
> | ||
<strong>B</strong> | ||
</TooltipToggleButton> | ||
<TooltipToggleButton | ||
color={ | ||
selectedFormats.has(FormatType.STRIKETHROUGH) | ||
? "primary" | ||
: "secondary" | ||
} | ||
title={"Cmd+Shift+X / Ctrl+Shfit+X"} | ||
value={FormatType.STRIKETHROUGH} | ||
> | ||
~ | ||
</TooltipToggleButton> | ||
<TooltipToggleButton | ||
color={selectedFormats.has(FormatType.CODE) ? "primary" : "secondary"} | ||
title={"Cmd+E / Ctrl+E"} | ||
value={FormatType.CODE} | ||
> | ||
{"</>"} | ||
</TooltipToggleButton> | ||
</Stack> | ||
</ToggleButtonGroup> | ||
</Stack> | ||
</Popover> | ||
); | ||
} | ||
|
||
export default ToolBar; |
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.