Skip to content

Commit

Permalink
feat(editor): conditionally render toolbar based on props and remove …
Browse files Browse the repository at this point in the history
…unused code

The toolbar is now conditionally rendered based on the `toolbar` and `editable` props. The `fp-ts` library is used to handle the nullable `toolbar` prop and the boolean `editable` prop. Unnecessary commented-out code and styles were removed to improve code readability.
  • Loading branch information
ktun95 committed Feb 14, 2025
1 parent 0c162c5 commit c658689
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions packages/editor/src/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin"
import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary"
import { Grid } from "@material-ui/core"
import { pipe } from "fp-ts/function"
import { match as Bmatch } from "fp-ts/boolean"
import {
getOrElse as OgetOrElse,
fromNullable as OfromNullable,
Expand Down Expand Up @@ -53,7 +54,6 @@ const Editor = ({
OgetOrElse(() => initialStateString as InitialEditorStateType),
)
const placeholderClasses = useEditorPlaceholderStyles()
// const persistencePluginStyles = usePersistencePluginStyles()
const editorAreaClasses = useEditorAreaStyles({ editable })

return (
Expand All @@ -71,20 +71,22 @@ const Editor = ({
<WidthTablePlugin />
<TableActionPlugin />
<HistoryPlugin />
{/* {content?.storageKey ? (
<LocalPersistencePlugin storageKey={content.storageKey} />
) : (
<></>
)} */}
<Grid container spacing={1} direction="column">
{/* <Grid item className={persistencePluginStyles.root}> */}
{toolbar ? <Grid item>{toolbar}</Grid> : <></>}
{editable ? (
<Grid item>
<DictybaseToolbar />
</Grid>
) : (
<></>
{pipe(
toolbar,
OfromNullable,
Omap((tb) => <Grid item>{tb}</Grid>),
)}
{pipe(
editable,
Bmatch(
() => <></>,
() => (
<Grid item>
<DictybaseToolbar />
</Grid>
),
),
)}
<Grid item>
<div>
Expand Down

0 comments on commit c658689

Please sign in to comment.