diff --git a/library/lib/App.tsx b/library/lib/App.tsx
index 78638c1..e4f0d46 100644
--- a/library/lib/App.tsx
+++ b/library/lib/App.tsx
@@ -10,6 +10,7 @@ import {
MarkerType,
ConnectionLineType,
ConnectionMode,
+ ReactFlowInstance,
} from "@xyflow/react"
import "@xyflow/react/dist/style.css"
@@ -29,7 +30,11 @@ const defaultEdgeOptions: DefaultEdgeOptions = {
style: { strokeWidth: 2 },
}
-function App() {
+interface AppProps {
+ onReactFlowInit: (instance: ReactFlowInstance) => void
+}
+
+function App({ onReactFlowInit }: AppProps) {
return (
onReactFlowInit(instance)}
minZoom={MIN_SCALE_TO_ZOOM_OUT}
maxZoom={MAX_SCALE_TO_ZOOM_IN}
>
@@ -51,10 +57,10 @@ function App() {
)
}
-export function AppWithProvider() {
+export function AppWithProvider({ onReactFlowInit }: AppProps) {
return (
-
+
)
}
diff --git a/library/lib/index.tsx b/library/lib/index.tsx
index 9f0bbcc..394c07f 100644
--- a/library/lib/index.tsx
+++ b/library/lib/index.tsx
@@ -10,7 +10,13 @@ export class Apollon2 {
constructor(element: HTMLElement) {
this.root = ReactDOM.createRoot(element)
- this.root.render()
+ this.root.render(
+
+ )
+ }
+
+ private setReactFlowInstance(instance: ReactFlowInstance) {
+ this.reactFlowInstance = instance
}
public getNodes(): Node[] {