-
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.
- Loading branch information
Showing
4 changed files
with
227 additions
and
437 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,13 @@ | ||
import React from 'react'; | ||
import styled from '@emotion/styled'; | ||
import { useFormContext } from 'react-hook-form'; | ||
import CodeMirrorMerge from 'react-codemirror-merge'; | ||
import { EditorView } from 'codemirror'; | ||
import { EditorState } from '@codemirror/state'; | ||
import { vscodeDark } from '@uiw/codemirror-theme-vscode'; | ||
import { DiffEditor as MonacoDiffEditor, DiffEditorProps } from '@monaco-editor/react'; | ||
|
||
export const DiffEditor: React.FC<DiffEditorProps> = (props) => { | ||
const { setValue } = useFormContext(); | ||
const Original = CodeMirrorMerge.Original; | ||
const Modified = CodeMirrorMerge.Modified; | ||
|
||
const onChangeOriginal = React.useCallback( | ||
(value) => { | ||
setValue('original', value); | ||
}, | ||
[setValue], | ||
); | ||
|
||
const onChangeModified = React.useCallback( | ||
(value) => { | ||
setValue('modified', value); | ||
}, | ||
[setValue], | ||
); | ||
|
||
return ( | ||
<CodeMirrorMerge theme={vscodeDark} orientation="a-b"> | ||
<Original onChange={onChangeOriginal} value={props.original} /> | ||
<Modified onChange={onChangeModified} value={props.modified} extensions={[]} /> | ||
</CodeMirrorMerge> | ||
<StyledWrapper> | ||
<MonacoDiffEditor className="diff-editor" height="80vh" theme="vs-dark" {...props} /> | ||
</StyledWrapper> | ||
); | ||
}; | ||
|
||
const StyledWrapper = styled.div``; |
Oops, something went wrong.