-
Notifications
You must be signed in to change notification settings - Fork 46
/
prismeditor.html
67 lines (62 loc) · 1.6 KB
/
prismeditor.html
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!doctype html5>
<html>
<head>
<title>Prism Editor</title>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/themes/prism.min.css" />
<style>
pre {
word-wrap: normal;
height: 400px;
width: 600px;
border: 1px solid black;
padding: 5px;
overflow: auto;
display: block;
}
</style>
</head>
<body>
<pre contenteditable class=language-markup ><!doctype html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<style>
/* inline styles work */
body {
font-size: 18px;
}
</style>
</head>
<body>
<script>
// inline script works
alert('hello, world');
</script>
</body>
</html></pre>
<label><input type=checkbox id=autoindent checked /> Autoindent</label>
<script src=https://cdn.jsdelivr.net/npm/prismjs data-manual></script>
<script src="../../historystack/history.js"></script>
<script src="../bililiteRange.js"></script>
<script src="../bililiteRange.undo.js"></script>
<script src="../bililiteRange.lines.js"></script>
<script>
const editor = document.querySelector('pre');
const rng = bililiteRange(editor)
Prism.highlightElement(editor);
// add the undo's
rng.initUndo().data.autoindent = true; // init
rng.listen('input', evt => {
rng.bounds('selection');
Prism.highlightElement(editor);
rng.select();
});
var ai = document.getElementById('autoindent');
ai.addEventListener('change', function(){
rng.data.autoindent = this.checked;
});
</script>
</body>
</html>