Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Fix multiple prosemirror blocks

Tomas Valenta1c9d36fd2880
diff --git a/components/Editor/RouteEditor/PromptEditor.tsx b/components/Editor/RouteEditor/PromptEditor.tsx
index 0eb188c9e..34b237a8c 100644
--- a/components/Editor/RouteEditor/PromptEditor.tsx
+++ b/components/Editor/RouteEditor/PromptEditor.tsx
@@ -18,7 +18,6 @@ function PromptEditor({ onChange, block }: Props) {
<div className="
flex
w-full
- h-full
pt-6
border-t
border-slate-200
diff --git a/hooks/useBlock.ts b/hooks/useBlock.ts
index 194d7d21f..122c139ba 100644
--- a/hooks/useBlock.ts
+++ b/hooks/useBlock.ts
@@ -1,4 +1,4 @@
-import { useCallback } from 'react'
+import { useCallback, useMemo } from 'react'
import { Route, BlockType, Block } from 'state/store'
import { useStateStore } from 'state/StoreProvider'
@@ -7,13 +7,17 @@ function useBlock(blockType: BlockType, position: number, route?: Route): [Block
const changeBlock = selectors.use.changeBlock()
- let count = 0
- const blockIdx = route?.blocks.findIndex(r => {
- if (r.type === blockType) {
- count++
- return count = position
- }
- })
+ const blockIdx = useMemo(() => {
+ let count = 0
+ return route?.blocks.findIndex((r, i) => {
+ console.log(blockType, position, count, r.type)
+ if (r.type === blockType) {
+ count++
+ return count === position
+ }
+ return false
+ })
+ }, [route, position, blockType])
const block = blockIdx !== undefined &&
blockIdx !== -1 &&