@@ -20,7 +20,7 @@ import { cytoscape } from "../lib/cytoscape";
2020import { getDoc , setMetaImmer , subscribeToDoc } from "../lib/docHelpers" ;
2121import { getGetSize , TGetSize } from "../lib/getGetSize" ;
2222import { getLayout } from "../lib/getLayout" ;
23- import { getUserStyle } from "../lib/getTheme" ;
23+ import { getUserStyle , useUserStyle } from "../lib/getTheme" ;
2424import { DEFAULT_GRAPH_PADDING } from "../lib/graphOptions" ;
2525import {
2626 useBackgroundColor ,
@@ -67,6 +67,7 @@ export default function Graph({ shouldResize }: { shouldResize: number }) {
6767 const themeKey = useThemeKey ( ) ;
6868 const theme = useCurrentTheme ( themeKey ) as unknown as Theme ;
6969 const bg = useBackgroundColor ( theme ) ;
70+ const userStyle = useUserStyle ( ) ;
7071
7172 const getSize = useRef < TGetSize > ( getGetSize ( theme ) ) ;
7273 const parser = useParser ( ) ;
@@ -115,8 +116,8 @@ export default function Graph({ shouldResize }: { shouldResize: number }) {
115116
116117 // Apply theme
117118 useEffect ( ( ) => {
118- getStyleUpdater ( { cy, errorCatcher, bg } ) ( theme ) ;
119- } , [ bg , theme ] ) ;
119+ getStyleUpdater ( { cy, errorCatcher, bg, userStyle } ) ( theme ) ;
120+ } , [ bg , theme , userStyle ] ) ;
120121
121122 const throttleUpdate = useMemo (
122123 ( ) =>
@@ -316,17 +317,18 @@ function getStyleUpdater({
316317 cy,
317318 errorCatcher,
318319 bg,
320+ userStyle = [ ] ,
319321} : {
320322 cy : React . MutableRefObject < cytoscape . Core | undefined > ;
321323 errorCatcher : React . MutableRefObject < cytoscape . Core | undefined > ;
322324 bg ?: string ;
325+ userStyle : cytoscape . StylesheetStyle [ ] ;
323326} ) {
324327 return throttle ( ( theme : Theme ) => {
325328 if ( ! cy . current ) return ;
326329 if ( ! errorCatcher . current ) return ;
327330 try {
328- // Prepare Styles
329- const style = buildStylesForGraph ( theme , getUserStyle ( ) , bg ) ;
331+ const style = buildStylesForGraph ( theme , userStyle , bg ) ;
330332
331333 // Test Error First
332334 errorCatcher . current . json ( { style } ) ;
0 commit comments