Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
Add multiple editors
Tomas Valenta4af5db49280f
diff --git a/api-service/playground/src/app.ts b/api-service/playground/src/app.tsindex d3b209a98..2150fe98b 100644--- a/api-service/playground/src/app.ts+++ b/api-service/playground/src/app.ts@@ -16,7 +16,7 @@ app.use(urlencoded({extended: true,}),- morgan('tiny')+ morgan('tiny'),)app.use(json())diff --git a/components/Editor/RouteEditor/index.tsx b/components/Editor/RouteEditor/index.tsxindex c4b0f8c6d..0ddfe8b4c 100644--- a/components/Editor/RouteEditor/index.tsx+++ b/components/Editor/RouteEditor/index.tsx@@ -9,8 +9,10 @@ export interface Props {}function RouteEditor({ route }: Props) {- const [requestBodyBlock, updateRequestBodyBlock] = useBlock('RequestBody', route)- const [promptBlock, updatePromptBlock] = useBlock('StructuredProse', route)+ const [requestBodyBlock, updateRequestBodyBlock] = useBlock('RequestBody', 1, route)+ const [promptBlock1, updatePromptBlock1] = useBlock('StructuredProse', 1, route)+ const [promptBlock2, updatePromptBlock2] = useBlock('StructuredProse', 2, route)+ const [promptBlock3, updatePromptBlock3] = useBlock('StructuredProse', 3, route)return (<div className="@@ -44,10 +46,22 @@ function RouteEditor({ route }: Props) {onChange={updateRequestBodyBlock}/>}- {promptBlock &&+ {promptBlock1 &&<PromptEditor- block={promptBlock}- onChange={updatePromptBlock}+ block={promptBlock1}+ onChange={updatePromptBlock1}+ />+ }+ {promptBlock2 &&+ <PromptEditor+ block={promptBlock2}+ onChange={updatePromptBlock2}+ />+ }+ {promptBlock3 &&+ <PromptEditor+ block={promptBlock3}+ onChange={updatePromptBlock3}/>}</div>diff --git a/hooks/useBlock.ts b/hooks/useBlock.tsindex d10c78030..194d7d21f 100644--- a/hooks/useBlock.ts+++ b/hooks/useBlock.ts@@ -2,12 +2,19 @@ import { useCallback } from 'react'import { Route, BlockType, Block } from 'state/store'import { useStateStore } from 'state/StoreProvider'-function useBlock(blockType: BlockType, route?: Route): [Block | undefined, (prompt: string) => void] {+function useBlock(blockType: BlockType, position: number, route?: Route): [Block | undefined, (prompt: string) => void] {const [selectors] = useStateStore()const changeBlock = selectors.use.changeBlock()- const blockIdx = route?.blocks.findIndex(r => r.type === blockType)+ let count = 0+ const blockIdx = route?.blocks.findIndex(r => {+ if (r.type === blockType) {+ count+++ return count = position+ }+ })+const block = blockIdx !== undefined &&blockIdx !== -1 &&route?.blocks.length !== undefined &&diff --git a/state/store.ts b/state/store.tsindex 4c731a477..48eb65232 100644--- a/state/store.ts+++ b/state/store.ts@@ -66,7 +66,12 @@ function createBlock(type: BlockType): Block {function getDefaultRoute(): Route {return {- blocks: [createBlock('RequestBody'), createBlock('StructuredProse')],+ blocks: [+ createBlock('RequestBody'),+ createBlock('StructuredProse'),+ createBlock('StructuredProse'),+ createBlock('StructuredProse'),+ ],method: Method.POST,route: '/',id: nanoid(),diff --git a/styles/prosemirror.css b/styles/prosemirror.cssindex 1ecf278a5..c687fbf6d 100644--- a/styles/prosemirror.css+++ b/styles/prosemirror.css@@ -1,6 +1,5 @@.ProseMirror {@apply prose prose-base text-slate-600;- @apply pb-40;/** NOTE: Disabling overflow anchor fixes a code cell scrolling bug* that happens in Chrome: