Skip to content

Instantly share code, notes, and snippets.

@CrowderSoup
Created January 22, 2013 05:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CrowderSoup/4592209 to your computer and use it in GitHub Desktop.
Save CrowderSoup/4592209 to your computer and use it in GitHub Desktop.
Simple example on how to use the ACE Editor
var dom = require("ace/lib/dom");
require("ace/commands/default_commands").commands.push({
name: "Toggle Fullscreen",
bindKey: "F11",
exec: function(editor) {
dom.toggleCssClass(document.body, "fullScreen");
dom.toggleCssClass(editor.container, "fullScreen");
editor.resize();
}
});
var editor = ace.edit("editor");
editor.setTheme("ace/theme/github");
editor.getSession().setMode("ace/mode/markdown");
var converter = Markdown.getSanitizingConverter();
editor.on("change", function(e){
var strHTML = converter.makeHtml(editor.getValue());
$('#editor_preview').html(strHTML);
});
function undo() {
editor.undo();
}
function redo() {
editor.redo();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment