WIP: toolbars

This commit is contained in:
2019-09-03 23:24:14 +03:00
parent 6e8c68966e
commit bb9f10c4ca

View File

@@ -1,9 +1,9 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<meta name="HandheldFriendly" content="True" /> <meta name="HandheldFriendly" content="True" />
<title>Editor</title> <title>Editor</title>
<style type="text/css" media="screen"> <style type="text/css" media="screen">
@@ -20,15 +20,15 @@
right: 0; right: 0;
} }
</style> </style>
</head> </head>
<body> <body>
<pre id="editor"></pre> <pre id="editor"></pre>
<script src="src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script> <script src="src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
<script> <script>
var buildDom = ace.require("ace/lib/dom").buildDom; var buildDom = ace.require("ace/lib/dom").buildDom;
var editor = ace.edit(); var editor = ace.edit("editor");
editor.setOptions({ editor.setOptions({
mode: "ace/mode/text", mode: "ace/mode/text",
theme: "ace/theme/twilight", theme: "ace/theme/twilight",
@@ -88,26 +88,12 @@
onclick: function() { onclick: function() {
editor.redo(); editor.redo();
} }
}, "redo"], }, "redo"]
["button", {
style: "font-weight: bold",
onclick: function() {
editor.insertSnippet("**${1:$SELECTION}**");
editor.renderer.scrollCursorIntoView()
}
}, "bold"],
["button", {
style: "font-style: italic",
onclick: function() {
editor.insertSnippet("*${1:$SELECTION}*");
editor.renderer.scrollCursorIntoView()
}
}, "Italic"],
], document.body, refs); ], document.body, refs);
document.body.appendChild(editor.container) document.body.appendChild(editor.container)
window.editor = editor; window.editor = editor;
</script> </script>
</body> </body>
</html> </html>