Skip to content

Commit

Permalink
ace editor plugin (ace.ajax.org), disabled by default
Browse files Browse the repository at this point in the history
  • Loading branch information
minad committed Oct 21, 2012
1 parent ce9f596 commit c50e25b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/config.yml.default
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ disabled_plugins:
- security/readonly_wiki
- security/private_wiki
- editor/recaptcha
- editor/ace

##################################################
# Rack middleware configurations
Expand Down
17 changes: 17 additions & 0 deletions plugins/editor/ace/init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
$(function() {
var textarea = $('#edit-content');
if (textarea.length == 1) {
textarea.hide().before('<div id="ace-editor" style="position:relative; width:100%; height: 40em"/>');
var editor = ace.edit('ace-editor');
var modes = {
'text/x-markdown': 'markdown',
'text/x-textile': 'textile'
};
if (window.Olelo && modes[Olelo.page_mime])
editor.getSession().setMode('ace/mode/' + modes[Olelo.page_mime]);
editor.getSession().setValue(textarea.val());
$('form').submit(function() {
textarea.val(editor.getSession().getValue());
});
}
});
7 changes: 7 additions & 0 deletions plugins/editor/ace/main.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
description 'Use ace editor'
dependencies 'utils/assets'
export_scripts '*.js'

Application.hook :head do
%{<script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript"/>}
end

0 comments on commit c50e25b

Please sign in to comment.