@@ -36,21 +36,11 @@ import Ansi from "ansi-to-react";
3636
3737import Box from "@mui/material/Box" ;
3838import InputBase from "@mui/material/InputBase" ;
39- import CircularProgress from "@mui/material/CircularProgress" ;
4039import Tooltip from "@mui/material/Tooltip" ;
4140import IconButton from "@mui/material/IconButton" ;
42- import PlayArrowIcon from "@mui/icons-material/PlayArrow" ;
43- import Stack from "@mui/material/Stack" ;
44- import Button from "@mui/material/Button" ;
45- import CircleIcon from "@mui/icons-material/Circle" ;
46- import CheckCircleIcon from "@mui/icons-material/CheckCircle" ;
47- import Grid from "@mui/material/Grid" ;
48- import PlayCircleOutlineIcon from "@mui/icons-material/PlayCircleOutline" ;
4941import DeleteIcon from "@mui/icons-material/Delete" ;
50- import ViewComfyIcon from "@mui/icons-material/ViewComfy" ;
51- import RectangleIcon from "@mui/icons-material/Rectangle" ;
52- import DisabledByDefaultIcon from "@mui/icons-material/DisabledByDefault" ;
5342import DragIndicatorIcon from "@mui/icons-material/DragIndicator" ;
43+ import FormatColorResetIcon from "@mui/icons-material/FormatColorReset" ;
5444
5545import {
5646 BoldExtension ,
@@ -99,6 +89,11 @@ import {
9989 useUpdateReason ,
10090 FloatingWrapper ,
10191 useMention ,
92+ ToggleBoldButton ,
93+ ToggleItalicButton ,
94+ ToggleUnderlineButton ,
95+ ToggleCodeButton ,
96+ ToggleStrikeButton ,
10297} from "@remirror/react" ;
10398import { FloatingToolbar , useExtensionEvent } from "@remirror/react" ;
10499import { TableExtension } from "@remirror/extension-react-tables" ;
@@ -260,7 +255,7 @@ function useUpdatePositionerOnMove() {
260255 return ;
261256}
262257
263- const FloatingLinkToolbar = ( { children } ) => {
258+ const EditorToolbar = ( ) => {
264259 const {
265260 isEditing,
266261 linkPositioner,
@@ -280,50 +275,69 @@ const FloatingLinkToolbar = ({ children }) => {
280275 clickEdit ( ) ;
281276 } , [ clickEdit ] ) ;
282277
283- const linkEditButtons = activeLink ? (
284- < CommandButtonGroup >
285- < CommandButton
286- commandName = "updateLink"
287- aria-label = "Edit link"
288- onSelect = { handleClickEdit }
289- icon = "pencilLine"
290- enabled
291- />
292- < CommandButton
293- commandName = "removeLink"
294- aria-label = "Remove link"
295- onSelect = { onRemove }
296- icon = "linkUnlink"
297- enabled
298- />
299- </ CommandButtonGroup >
300- ) : (
301- < CommandButtonGroup >
302- < CommandButton
303- commandName = "updateLink"
304- aria-label = "Add link"
305- onSelect = { handleClickEdit }
306- icon = "link"
307- enabled
308- />
309- </ CommandButtonGroup >
310- ) ;
311-
312278 return (
313279 < >
314280 { ! isEditing && (
315281 // By default, MUI's Popper creates a Portal, which is a ROOT html
316282 // elements that prevents paning on reactflow canvas. Therefore, we
317283 // disable the portal behavior.
318- < FloatingToolbar disablePortal >
319- { linkEditButtons }
320- { children }
321- </ FloatingToolbar >
322- ) }
323- { ! isEditing && empty && (
324- < FloatingToolbar positioner = { linkPositioner } disablePortal >
325- { linkEditButtons }
326- { children }
284+ < FloatingToolbar
285+ disablePortal
286+ sx = { {
287+ button : {
288+ padding : 0 ,
289+ border : "none" ,
290+ borderRadius : "5px" ,
291+ marginLeft : "5px" ,
292+ } ,
293+ paddingX : "4px" ,
294+ border : "2px solid grey" ,
295+ borderRadius : "5px" ,
296+ alignItems : "center" ,
297+ backgroundColor : "white" ,
298+ } }
299+ >
300+ < ToggleBoldButton />
301+ < ToggleItalicButton />
302+ < ToggleUnderlineButton />
303+ < ToggleStrikeButton />
304+ < ToggleCodeButton />
305+ { activeLink && (
306+ < CommandButton
307+ commandName = "updateLink"
308+ aria-label = "Edit link"
309+ onSelect = { handleClickEdit }
310+ icon = "pencilLine"
311+ enabled
312+ />
313+ ) }
314+ { activeLink && (
315+ < CommandButton
316+ commandName = "removeLink"
317+ aria-label = "Remove link"
318+ onSelect = { onRemove }
319+ icon = "linkUnlink"
320+ enabled
321+ />
322+ ) }
323+ { ! activeLink && (
324+ < CommandButton
325+ commandName = "updateLink"
326+ aria-label = "Add link"
327+ onSelect = { handleClickEdit }
328+ icon = "link"
329+ enabled
330+ />
331+ ) }
332+ < SetHighlightButton color = "lightpink" />
333+ < SetHighlightButton color = "yellow" />
334+ < SetHighlightButton color = "lightgreen" />
335+ < SetHighlightButton color = "lightcyan" />
336+ < SetHighlightButton />
337+
338+ { /* <TextAlignmentButtonGroup /> */ }
339+ { /* <IndentationButtonGroup /> */ }
340+ { /* <BaselineButtonGroup /> */ }
327341 </ FloatingToolbar >
328342 ) }
329343
@@ -384,14 +398,24 @@ export const SetHighlightButton: React.FC<
384398 < CommandButton
385399 { ...props }
386400 commandName = "setHighlight"
387- label = { color ? "Highlight" : "Un- Highlight" }
401+ label = { color ? "Highlight" : "Clear Highlight" }
388402 enabled = { enabled }
389403 onSelect = { handleSelect }
390404 icon = {
391- < IconBase viewBox = "0 0 24 24" >
392- color === null ? < DisabledByDefaultIcon /> :{ " " }
393- < RectangleIcon sx = { { color } } />
394- </ IconBase >
405+ color ? (
406+ < Box
407+ sx = { {
408+ backgroundColor : color ,
409+ paddingX : "4px" ,
410+ borderRadius : "4px" ,
411+ lineHeight : 1.2 ,
412+ } }
413+ >
414+ A
415+ </ Box >
416+ ) : (
417+ < FormatColorResetIcon />
418+ )
395419 }
396420 />
397421 ) ;
@@ -616,28 +640,7 @@ const MyEditor = ({
616640 ] }
617641 />
618642
619- { ! isGuest && (
620- < FloatingLinkToolbar >
621- < FormattingButtonGroup />
622- < VerticalDivider />
623- < CommandButtonGroup >
624- { /* <HeadingLevelButtonGroup /> */ }
625-
626- { /* <ListButtonGroup /> */ }
627- < SetHighlightButton color = "lightpink" />
628- < SetHighlightButton color = "yellow" />
629- < SetHighlightButton color = "lightgreen" />
630- < SetHighlightButton color = "lightcyan" />
631- < SetHighlightButton />
632- </ CommandButtonGroup >
633- { /* <FormattingButtonGroup /> */ }
634- { /* <DecreaseIndentButton /> */ }
635- { /* <IncreaseIndentButton /> */ }
636- { /* <TextAlignmentButtonGroup /> */ }
637- { /* <IndentationButtonGroup /> */ }
638- { /* <BaselineButtonGroup /> */ }
639- </ FloatingLinkToolbar >
640- ) }
643+ { ! isGuest && < EditorToolbar /> }
641644
642645 { /* <Menu /> */ }
643646 </ Remirror >
0 commit comments