Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Fix multiple prosemirror blocks
Tomas Valenta1c9d36fd2880
diff --git a/components/Editor/RouteEditor/PromptEditor.tsx b/components/Editor/RouteEditor/PromptEditor.tsxindex 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="flexw-full- h-fullpt-6border-tborder-slate-200diff --git a/hooks/useBlock.ts b/hooks/useBlock.tsindex 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): [Blockconst 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 &&