|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <!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;
- background-color: #222;
- }
- .inner {
- margin-top: 32px;
- position: absolute;
- top: 0;
- bottom: 0;
- left: 0;
- right: 0;
- }
- </style>
- </head>
- <body>
- <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>
-
- <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/ambiance",
- 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>
|