reverted toolbar
This commit is contained in:
153
ace/index.html
153
ace/index.html
@@ -1,119 +1,54 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||||
<meta name="HandheldFriendly" content="True" />
|
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
<meta name="HandheldFriendly" content="True" />
|
||||||
<title>Editor</title>
|
<title>Editor</title>
|
||||||
<style type="text/css" media="screen">
|
<style type="text/css" media="screen">
|
||||||
.ace_editor,
|
body {
|
||||||
.toolbar {
|
overflow: hidden;
|
||||||
border: 1px solid lightgray;
|
}
|
||||||
margin: auto;
|
|
||||||
width: 80%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_editor {
|
|
||||||
height: 200px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
|
#editor {
|
||||||
|
margin: 0;
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<script src="require.js"></script>
|
<pre id="editor"></pre>
|
||||||
<script>
|
|
||||||
// setup paths
|
|
||||||
require.config({
|
|
||||||
paths: {
|
|
||||||
"ace": "src-min-noconflict"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// load ace and extensions
|
|
||||||
require(["ace/ace", "ace/ext-language_tools"], function(ace) {
|
|
||||||
//var buildDom = require("ace/lib/dom").buildDom;
|
|
||||||
var editor = ace.edit();
|
|
||||||
editor.setOptions({
|
|
||||||
theme: "ace/theme/twilight",
|
|
||||||
showPrintMargin: false,
|
|
||||||
wrap: true,
|
|
||||||
indentedSoftWrap: true,
|
|
||||||
showFoldWidgets: false,
|
|
||||||
showLineNumbers: true,
|
|
||||||
showGutter: false,
|
|
||||||
autoScrollEditorIntoView: true
|
|
||||||
});
|
|
||||||
var refs = {};
|
|
||||||
|
|
||||||
function updateToolbar() {
|
<script src="src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
|
||||||
refs.undoButton.disabled = !editor.session.getUndoManager().hasUndo();
|
<script>
|
||||||
refs.redoButton.disabled = !editor.session.getUndoManager().hasRedo();
|
var editor = ace.edit("editor");
|
||||||
}
|
editor.setOptions({
|
||||||
editor.on("input", updateToolbar);
|
mode: "ace/mode/markdown",
|
||||||
|
theme: "ace/theme/twilight",
|
||||||
if (localStorage.getItem("acetest") !== null) {
|
showPrintMargin: false,
|
||||||
editor.setValue(localStorage.getItem("acetest"));
|
wrap: true,
|
||||||
editor.clearSelection();
|
indentedSoftWrap: true,
|
||||||
}
|
showFoldWidgets: false,
|
||||||
|
showLineNumbers: true,
|
||||||
editor.getSession().on('change', function () {
|
showGutter: false,
|
||||||
localStorage.setItem("acetest", editor.getSession().getValue());
|
autoScrollEditorIntoView: true
|
||||||
});
|
})
|
||||||
|
|
||||||
function save() {
|
if (localStorage.getItem("acetest") !== null) {
|
||||||
alert("not yet implemented");
|
editor.setValue(localStorage.getItem("acetest"));
|
||||||
}
|
editor.clearSelection();
|
||||||
editor.commands.addCommand({
|
}
|
||||||
name: "save",
|
|
||||||
exec: save,
|
editor.getSession().on('change', function () {
|
||||||
bindKey: {
|
localStorage.setItem("acetest", editor.getSession().getValue());
|
||||||
win: "ctrl-s",
|
});
|
||||||
mac: "cmd-s"
|
</script>
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
buildDom(["div", {
|
|
||||||
class: "toolbar"
|
|
||||||
},
|
|
||||||
["button", {
|
|
||||||
ref: "saveButton",
|
|
||||||
onclick: save
|
|
||||||
}, "save"],
|
|
||||||
["button", {
|
|
||||||
ref: "undoButton",
|
|
||||||
onclick: function() {
|
|
||||||
editor.undo();
|
|
||||||
}
|
|
||||||
}, "undo"],
|
|
||||||
["button", {
|
|
||||||
ref: "redoButton",
|
|
||||||
onclick: function() {
|
|
||||||
editor.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.appendChild(editor.container)
|
|
||||||
|
|
||||||
window.editor = editor;
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user