Skip to content

Feature yaml editor #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Aug 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: reviews
  • Loading branch information
cr-ruhanmuzaffar committed Aug 16, 2024
commit f916e2efb67310ac92d7e23ec82691630d63268a
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { React, useState, useEffect } from "react";
import React, { useState, useEffect } from "react";

import AceEditor from "react-ace";
import "ace-builds/src-noconflict/theme-github";
Expand All @@ -15,13 +15,7 @@ const ajv = new Ajv({ allErrors: true });
import Schema from "../../../static/schema/schema.v2.json";

const validate = ajv.compile(Schema.definitions.schema);

export default function YamlEditor() {
const [value, setValue] = useState("");
const [annotations, setAnnotations] = useState([]);

useEffect(() => {
const initialValue = `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
const initialValue = `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
language: "en-US"
early_access: false
reviews:
Expand All @@ -38,6 +32,11 @@ chat:
auto_reply: true

`;
export default function YamlEditor() {
const [value, setValue] = useState(initialValue);
const [annotations, setAnnotations] = useState([]);

useEffect(() => {
setValue(initialValue);
validateAndSetAnnotations(initialValue);
}, []);
Expand Down Expand Up @@ -135,21 +134,24 @@ chat:
}

return (
<AceEditor
mode="yaml"
theme="github"
onChange={onChange}
value={value}
name="yaml-editor"
editorProps={{ $blockScrolling: true }}
setOptions={{
useWorker: false,
showPrintMargin: false,
showGutter: true,
}}
annotations={annotations}
width="100%"
height="400px"
/>
<div className="m4">
<AceEditor
mode="yaml"
theme="github"
onChange={onChange}
value={value}
name="yaml-editor"
editorProps={{ $blockScrolling: true }}
setOptions={{
useWorker: false,
showPrintMargin: false,
showGutter: true,
}}
annotations={annotations}
width="100%"
height="400px"
/>
<br />
</div>
);
}