-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f7722ea
commit 5578261
Showing
5 changed files
with
55 additions
and
56 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 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,42 @@ | ||
import { useEffect, RefObject, useContext } from "react"; | ||
import { EditorController, darkTheme } from "blocky-core"; | ||
import { BlockyEditor } from "blocky-react"; | ||
import { Theme, blockyExampleFont } from "@pkg/app/themeSwitch"; | ||
|
||
interface BlockyEditorWithThemeProps { | ||
controller: EditorController | null; | ||
ignoreInitEmpty?: boolean; | ||
autoFocus?: boolean; | ||
scrollContainer?: RefObject<HTMLElement>; | ||
} | ||
|
||
function BlockyEditorWithTheme(props: BlockyEditorWithThemeProps) { | ||
const { controller, scrollContainer } = props; | ||
const theme = useContext(Theme); | ||
const darkMode = theme.darkMode; | ||
useEffect(() => { | ||
if (!controller) { | ||
return; | ||
} | ||
if (darkMode) { | ||
controller.themeData = { | ||
...darkTheme, | ||
font: blockyExampleFont, | ||
}; | ||
} else { | ||
controller.themeData = { | ||
font: blockyExampleFont, | ||
}; | ||
} | ||
}, [controller, darkMode]); | ||
return ( | ||
<BlockyEditor | ||
controller={props.controller} | ||
autoFocus={props.autoFocus} | ||
ignoreInitEmpty={props.ignoreInitEmpty} | ||
scrollContainer={scrollContainer} | ||
/> | ||
); | ||
} | ||
|
||
export default BlockyEditorWithTheme; |
5578261
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
blocky-editor – ./
blocky-editor-git-master-vincentdchan.vercel.app
blocky-editor.dev
blocky-editor.vercel.app
blocky-editor-vincentdchan.vercel.app
www.blocky-editor.dev