-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodemirror-client.js
41 lines (41 loc) · 1.46 KB
/
codemirror-client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import * as CodeMirror from 'codemirror';
import 'codemirror/lib/codemirror.css';
import 'codemirror/mode/javascript/javascript';
import './codemirror-styles.css';
import "./tomorrow-night-eighties.css"
import mainTXT from './main.txt'
console.log(mainTXT);
const editors = document.createElement('div');
editors.classList.add('editors')
document.body.appendChild(editors);
const editorTextArea1 = document.createElement('textarea');
editors.append(editorTextArea1);
const editorTextArea2 = document.createElement('textarea');
editors.append(editorTextArea2);
const editor1=CodeMirror.fromTextArea(editorTextArea1,{
// lineNumbers:true,
theme: 'tomorrow-night-eighties',
});
const editor2=CodeMirror.fromTextArea(editorTextArea2,{
// lineNumbers:true,
theme: 'tomorrow-night-eighties',
});
const canvas = document.createElement('canvas');
canvas.classList.add('canvas');
document.body.appendChild(canvas)
const context = canvas.getContext('2d');
context.fillStyle = 'white'
context.fillRect(0,0,canvas.width,canvas.height);
for (let index = 0; index < 10; index++) {
context.beginPath()
context.moveTo(Math.random()*canvas.width,Math.random()*canvas.height);
context.lineTo(Math.random()*canvas.width,Math.random()*canvas.height);
context.stroke();
}
fetch(mainTXT)
.then(response=>response.text())
.then(code=>{
console.log('code: ',code);
editor1.setValue(code);
editor2.setValue(code)
})