-
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
0 parents
commit 14cf9d5
Showing
6 changed files
with
82 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import * as React from 'react'; | ||
|
||
// formating styles (makes sure text stays inside editor box) | ||
import 'codemirror/lib/codemirror.css'; | ||
|
||
// aesthetic styles | ||
import 'codemirror/theme/material.css'; // syntax highlighting | ||
import 'codemirror/mode/xml/xml'; // theme styles | ||
|
||
import { Controlled as ControlledEditor } from 'react-codemirror2'; | ||
|
||
import './style.css'; | ||
|
||
export default function App() { | ||
const [value, setValue] = React.useState('bruh'); | ||
return ( | ||
<div> | ||
<h1>Hello StackBlitz!</h1> | ||
<p>Start editing to see some magic happen :)</p> | ||
<ControlledEditor | ||
onBeforeChange={(editor, data, value) => { | ||
setValue(value); | ||
}} | ||
value={value} | ||
className="code-mirror-wrapper" | ||
options={{ | ||
lineWrapping: true, | ||
lint: true, | ||
mode: 'xml', | ||
theme: 'material', | ||
lineNumbers: true, | ||
}} | ||
/> | ||
</div> | ||
); | ||
} |
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,3 @@ | ||
# react-codemirror-demos | ||
|
||
[Edit on StackBlitz ⚡️](https://stackblitz.com/edit/react-ts-4hgcxn) |
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 @@ | ||
<div id="root"></div> |
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,17 @@ | ||
import * as React from 'react'; | ||
import { StrictMode } from 'react'; | ||
import { createRoot } from 'react-dom/client'; | ||
|
||
import App from './App'; | ||
|
||
const rootElement = document.getElementById('root'); | ||
const root = createRoot(rootElement); | ||
|
||
root.render( | ||
// removed strickmode to fix doubled editor bug | ||
// see source for more details: | ||
// https://stackoverflow.com/questions/72464452/codemirror-editor-duplicating | ||
// <StrictMode> | ||
<App /> | ||
// </StrictMode> | ||
); |
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,22 @@ | ||
{ | ||
"name": "react-ts", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@types/react": "^18.0.27", | ||
"@types/react-dom": "^18.0.10", | ||
"codemirror": "5.x", | ||
"react": "^18.2.0", | ||
"react-codemirror2": "^7.2.1", | ||
"react-dom": "^18.2.0" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test --env=jsdom", | ||
"eject": "react-scripts eject" | ||
}, | ||
"devDependencies": { | ||
"react-scripts": "latest" | ||
} | ||
} |
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,3 @@ | ||
h1, p { | ||
font-family: Lato; | ||
} |