|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <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="HandheldFriendly" content="True" />
- <title>Editor</title>
- <style type="text/css" media="screen">
- body {
- overflow: hidden;
- }
-
- #editor {
- margin-top: 30px;
- position: absolute;
- top: 0;
- bottom: 0;
- left: 0;
- right: 0;
- }
- </style>
- </head>
- <body>
- <div class="wrapper">
- <!--<div class="toolbar">
- <button id="btnSave" class="btn btn-primary btn-xs">save</button>
- <button id="btnUndo" class="btn btn-primary btn-xs">undo</button>
- <button id="btnRedo" class="btn btn-primary btn-xs">redo</button>
- </div>-->
- <div class="inner" id="editor"></div>
- </div>
-
- <script src="src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
- <script>
- var buildDom = ace.require("ace/lib/dom").buildDom;
- var editor = ace.edit("editor");
- editor.setOptions({
- mode: "ace/mode/text",
- theme: "ace/theme/twilight",
- showPrintMargin: false,
- wrap: true,
- indentedSoftWrap: true,
- showFoldWidgets: false,
- showLineNumbers: true,
- showGutter: false,
- autoScrollEditorIntoView: true
- });
-
- function updateToolbar() {
- document.getElementById("btnUndo") = !editor.session.getUndoManager().hasUndo();
- document.getElementById("btnRedo") = !editor.session.getUndoManager().hasRedo();
- }
- editor.on("input", updateToolbar);
-
- if (localStorage.getItem("acetest") !== null) {
- editor.setValue(localStorage.getItem("acetest"));
- editor.clearSelection();
- }
-
- editor.getSession().on('change', function () {
- localStorage.setItem("acetest", editor.getSession().getValue());
- });
-
- function save() {
- alert("not yet implemented");
- }
-
- editor.commands.addCommand({
- name: "save",
- exec: save,
- bindKey: {
- win: "ctrl-s",
- mac: "cmd-s"
- }
- });
-
- $('#btnSave').onClick(function(){
- save();
- });
-
- $('#btnUndo').onClick(function(){
- editor.undo();
- });
-
- $('#btnRow').onClick(function(){
- editor.redo();
- });
-
- window.editor = editor;
- </script>
-
- </body>
- </html>
|