forked from langchain-ai/open-canvas
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement a proper code editor and clean state
- Loading branch information
1 parent
828e2c7
commit e6f2626
Showing
16 changed files
with
436 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* .codeMirrorCustom :global(.cm-focused) { | ||
outline: none !important; | ||
} | ||
.codeMirrorCustom :global(.cm-editor) { | ||
border: none !important; | ||
} | ||
.codeMirrorCustom :global(.cm-focused) { | ||
outline: none !important; | ||
} | ||
.codeMirrorCustom :global(.cm-editor) { | ||
border: none !important; | ||
} | ||
.codeMirrorCustom :global(.cm-gutters) { | ||
border-right: none !important; | ||
} */ | ||
|
||
.codeMirrorCustom { | ||
height: 100vh !important; | ||
overflow: hidden; | ||
} | ||
|
||
.codeMirrorCustom :global(.cm-editor) { | ||
height: 100% !important; | ||
border: none !important; | ||
} | ||
|
||
.codeMirrorCustom :global(.cm-scroller) { | ||
overflow: auto; | ||
} | ||
|
||
.codeMirrorCustom :global(.cm-gutters) { | ||
height: 100% !important; | ||
border-right: none !important; | ||
} | ||
|
||
.codeMirrorCustom :global(.cm-focused) { | ||
outline: none !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Artifact } from "@/types"; | ||
import { useState } from "react"; | ||
import CodeMirror from "@uiw/react-codemirror"; | ||
import { javascript } from "@codemirror/lang-javascript"; | ||
|
||
// Add this import for styling | ||
import styles from "./CodeRenderer.module.css"; | ||
|
||
export interface CodeRendererProps { | ||
artifact: Artifact; | ||
} | ||
|
||
export function CodeRenderer(props: CodeRendererProps) { | ||
const [code, setCode] = useState(""); | ||
|
||
if (!props.artifact.content) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<CodeMirror | ||
className={`w-full min-h-full ${styles.codeMirrorCustom}`} | ||
value={props.artifact.content} | ||
height="800px" | ||
extensions={[javascript({ jsx: true })]} | ||
onChange={(c) => setCode(c)} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Markdown from "react-markdown"; | ||
import { Artifact } from "@/types"; | ||
|
||
export interface TextRendererProps { | ||
artifact: Artifact; | ||
} | ||
|
||
export function TextRenderer(props: TextRendererProps) { | ||
return ( | ||
<Markdown className="text-left leading-relaxed overflow-y-auto scrollbar-thin scrollbar-thumb-gray-300 scrollbar-track-gray-100"> | ||
{props.artifact.content} | ||
</Markdown> | ||
); | ||
} |
8 changes: 4 additions & 4 deletions
8
...ponents/actions_toolbar/LengthOptions.tsx → ...tifacts/actions_toolbar/LengthOptions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ents/actions_toolbar/TranslateOptions.tsx → ...acts/actions_toolbar/TranslateOptions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.